如何检查 Power BI 中的行是否唯一?
How to check if row is unique in Power BI?
我正在使用 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行),根据索引比较需要很长时间。强大的查询编辑器中还有哪些其他方法可以有效地实现这一目标。
我这样做 - “if [Index] = 0 then 1 else if [#"Employee ID"] = #"Added Index"[#"Employee ID"]{[Index]-1} then 0 else 1"
一种方法是对 EmployeeID 进行分组并向组添加索引
那么展开的时候,每个EmployeeID都会被连续编号。
任何带有 1 的东西都应该保持为 1,而其他任何东西都应该变成零,你可以通过转换操作来做到这一点
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"
我正在使用 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行),根据索引比较需要很长时间。强大的查询编辑器中还有哪些其他方法可以有效地实现这一目标。 我这样做 - “if [Index] = 0 then 1 else if [#"Employee ID"] = #"Added Index"[#"Employee ID"]{[Index]-1} then 0 else 1"
一种方法是对 EmployeeID 进行分组并向组添加索引
那么展开的时候,每个EmployeeID都会被连续编号。
任何带有 1 的东西都应该保持为 1,而其他任何东西都应该变成零,你可以通过转换操作来做到这一点
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"