在 Power BI 或 DAX 中,当 B 列 = "Value" 时删除 A 列中的重复项
Remove duplicates in Column A when Column B = "Value" in power BI or DAX
我在使用 PowerBI 根据另一列的条件从一列中删除重复项时遇到困难。我的数据是这样的
Sample Data
正如您在示例数据中看到的,当 Status = 'False' 时,我想删除 ID 列中的重复项
所需的输出如下所示
Expected Output
非常感谢任何帮助
- 在 PQ 中(变换)
- 按 ID 分组
- 对于每个子表,如果有多行,select只有 Status=true 的行
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZC7DoAgDEX/hdmAt1KE0UEnJx+T8f9/Q5Iq1ESnkpyT21uOw8TOs2nMtuxjHuTgHVF+AZbN2RRhGub13wg1Ag64Bba4BYYIEpAKjw8n3YFIhGSD5rXCh9DrgCDY1/z4PqEVQRVMr09g4X25MLQqoHN4eF5wXg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Status = _t, Date = _t, Value = _t]),
#"Correct Error in Source" = Table.TransformColumns(Source,{"Status", each if Text.StartsWith(_,"T") then true else false }),
#"Changed Type" = Table.TransformColumnTypes(#"Correct Error in Source",{{"ID", Int64.Type}, {"Status", type logical}, {"Date", type date}, {"Value", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {
{"deDupFalse", (t)=> if Table.RowCount(t) > 1 then Table.SelectRows(t, each [Status]=true) else t,
type table[Status=logical, Date=date, Value=number]}
}),
#"Expanded deDupFalse" = Table.ExpandTableColumn(#"Grouped Rows", "deDupFalse",{"Status","Date","Value"})
in
#"Expanded deDupFalse"
数据
过滤
我在使用 PowerBI 根据另一列的条件从一列中删除重复项时遇到困难。我的数据是这样的 Sample Data 正如您在示例数据中看到的,当 Status = 'False' 时,我想删除 ID 列中的重复项 所需的输出如下所示 Expected Output
非常感谢任何帮助
- 在 PQ 中(变换)
- 按 ID 分组
- 对于每个子表,如果有多行,select只有 Status=true 的行
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZC7DoAgDEX/hdmAt1KE0UEnJx+T8f9/Q5Iq1ESnkpyT21uOw8TOs2nMtuxjHuTgHVF+AZbN2RRhGub13wg1Ag64Bba4BYYIEpAKjw8n3YFIhGSD5rXCh9DrgCDY1/z4PqEVQRVMr09g4X25MLQqoHN4eF5wXg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Status = _t, Date = _t, Value = _t]),
#"Correct Error in Source" = Table.TransformColumns(Source,{"Status", each if Text.StartsWith(_,"T") then true else false }),
#"Changed Type" = Table.TransformColumnTypes(#"Correct Error in Source",{{"ID", Int64.Type}, {"Status", type logical}, {"Date", type date}, {"Value", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {
{"deDupFalse", (t)=> if Table.RowCount(t) > 1 then Table.SelectRows(t, each [Status]=true) else t,
type table[Status=logical, Date=date, Value=number]}
}),
#"Expanded deDupFalse" = Table.ExpandTableColumn(#"Grouped Rows", "deDupFalse",{"Status","Date","Value"})
in
#"Expanded deDupFalse"
数据
过滤