【问题标题】:How to check if row is unique in Power BI?如何检查 Power BI 中的行是否唯一?
【发布时间】:2021-09-20 14:23:48
【问题描述】:

我正在研究 PowerBI,我必须比较两行以检查并将 1 分配给其中一个值,并将 0 分配给休息。

例如-

数据是这样的:

Employee ID
    097647231  
    030300558     
    097647231
    040114563      
    097647231              
    040114563
    030300558  

我想要这样的东西:

Employee ID  1/0 
030300558     1
030300558     0
097647231     1
097647231     0
097647231     0
040114563     1 
040114563     0

文件非常大(将近 90,000 行),基于索引进行比较需要很长时间。电源查询编辑器中还有哪些其他方法可以有效地实现这一目标。 我正在这样做 - “如果 [Index] = 0 then 1 else if [#"Employee ID"] = #"Added Index"[#"Employee ID"]{[Index]-1} then 0 else 1"

【问题讨论】:

    标签: powerbi dax powerquery


    【解决方案1】:

    一种方法是在 EmployeeID 上进行分组并向组添加索引

    那么当你展开时,每个EmployeeID都会被连续编号。

    任何带有 1 的东西都应该保持 1,而其他任何东西都应该变成 0,这可以通过变换操作来实现

    let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Employee ID"}, {{"GRP", each Table.AddIndexColumn(_, "Index", 1, 1), type table}}),
    #"Expanded GRP" = Table.ExpandTableColumn(Group, "GRP", {"Index"}, {"Index"}),
    #"Transform" = Table.TransformColumns(#"Expanded GRP",{{"Index", each if _ =1 then 1 else 0, type number}})
    in #"Transform"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-29
      • 2021-08-28
      • 2018-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多