删除表格图中的重复数值。

huangapple go评论57阅读模式
英文:

Removing duplicate values in table chart

问题

"I want to remove or now display the "0" value with duplicate competency." (我想要移除或者不显示重复能力的“0”值。)

英文:

I would like to ask for your assistance, the table chart shows duplicate values but in power query it is just unique. Is there are DAX formula where it will be distinct in the table chart? Apologies as I am new to power bi. Please see sample images

I want to remove or now display the "0" value with duplicate competency.

Thank you

I want to remove or now display the "0" value with duplicate competency.

答案1

得分: 0

你可以尝试这个简单的DAX代码作为一个新的度量值:

Value Measure = 
VAR _val = SELECTEDVALUE ( 'Table'[Value] )
RETURN
IF ( _val <> 0 , _val )

在表可视化中使用这个度量值,与 ‘Table’[Competency] 列一起使用,并从可视化中移除 ‘Table’[Value] 列。

这将移除所有值为零的能力 - 不确定这是否符合你的要求,或者你只想要移除完全重复的情况,那需要稍微不同的公式,如下:

Advanced Value Measure =
VAR _good_symbol =
    UNICHAR ( 10003 )
VAR _bad_symbol =
    UNICHAR ( 10007 )
VAR _sum =
    SUMX ( 'Table', IF ( 'Table'[Value] = _good_symbol, 1 ) )
VAR _is_distinct =
    HASONEVALUE ( 'Table'[Competency] )
RETURN
    SWITCH (
        TRUE (),
        _is_distinct
            && _sum > 0, _good_symbol,
        _is_distinct
            && _sum = 0, _bad_symbol
    )

这将显示所有的能力,但会为没有带有 的行的能力分配一个

英文:

You can try this simple DAX code as a new measure:

Value Measure = 
VAR _val = SELECTEDVALUE ( &#39;Table&#39;[Value] )
RETURN
IF ( _val &lt;&gt; 0 , _val )

Use the measure in your table visualization together with the &#39;Table&#39;[Competency] column, and remove the &#39;Table&#39;[Value] column from the visual.

This removes all the competencies with zero-values - not sure if that is what you were after, or if you only wanted to remove exactly duplicates, that requires a slightly different formula, like this:

Advanced Value Measure =
VAR _good_symbol =
    UNICHAR ( 10003 )
VAR _bad_symbol =
    UNICHAR ( 10007 )
VAR _sum =
    SUMX ( &#39;Table&#39;, IF ( &#39;Table&#39;[Value] = _good_symbol, 1 ) )
VAR _is_distinct =
    HASONEVALUE ( &#39;Table&#39;[Competency] )
RETURN
    SWITCH (
        TRUE (),
        _is_distinct
            &amp;&amp; _sum &gt; 0, _good_symbol,
        _is_distinct
            &amp;&amp; _sum = 0, _bad_symbol
    )

This will show all the competencies, but assign a to the competencies that have no rows with .

答案2

得分: -1

以下是翻译好的内容:

在Power Query中执行以下步骤:

  1. 首先合并“Competency”和“Value”列。这里的合并意味着连接这两列。
  2. 在M代码中编写一步来删除包含“Business Process Management0”的行。
  3. 最后删除合并的列。

M代码:

let
    Source = Excel.Workbook(File.Contents("C:\Ashok\Power BI\Stack Overflow\Data_09jun23.xlsx"), null, true),
    Data_Sheet = Source{[Item="Data",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Data_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Competency", type text}, {"Value", Int64.Type}}),
    #"Inserted Merged Column" = Table.AddColumn(#"Changed Type", "Merged", each Text.Combine({[Competency], Text.From([Value], "en-US")}, ""), type text),
    #"Filtered Rows" = Table.SelectRows( #"Inserted Merged Column", each let thisrep = [Merged] in List.Count(List.Select({"Business Process Management0"}, each Text.Contains(thisrep, _))) = 0),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Merged"})
in
    #"Removed Columns"

注意:在复选标记的位置使用了数字1。

请注意,代码部分不会被翻译,只提供M代码的原文。

英文:

In Power Query do the following steps

  1. First merge Competency and Value columns. Merge here means concatenate both columns.
  2. Write a step in M code to remove rows containing "Business Process Management0".
  3. Finally remove Merged column.

M code:

let
    Source = Excel.Workbook(File.Contents(&quot;C:\Ashok\Power BI\Stack Overflow\Data_09jun23.xlsx&quot;), null, true),
    Data_Sheet = Source{[Item=&quot;Data&quot;,Kind=&quot;Sheet&quot;]}[Data],
    #&quot;Promoted Headers&quot; = Table.PromoteHeaders(Data_Sheet, [PromoteAllScalars=true]),
    #&quot;Changed Type&quot; = Table.TransformColumnTypes(#&quot;Promoted Headers&quot;,{{&quot;Competency&quot;, type text}, {&quot;Value&quot;, Int64.Type}}),
    #&quot;Inserted Merged Column&quot; = Table.AddColumn(#&quot;Changed Type&quot;, &quot;Merged&quot;, each Text.Combine({[Competency], Text.From([Value], &quot;en-US&quot;)}, &quot;&quot;), type text),
    #&quot;Filtered Rows&quot; = Table.SelectRows( #&quot;Inserted Merged Column&quot;, each let thisrep = [Merged] in List.Count(List.Select({&quot;Business Process Management0&quot;}, each Text.Contains(thisrep, _))) = 0),
    #&quot;Removed Columns&quot; = Table.RemoveColumns(#&quot;Filtered Rows&quot;,{&quot;Merged&quot;})
in
    #&quot;Removed Columns&quot;

删除表格图中的重复数值。

删除表格图中的重复数值。

删除表格图中的重复数值。

Note: Used 1 in place of check mark.

huangapple
  • 本文由 发表于 2023年6月9日 14:08:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437631.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定