Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, I need to remove the the ID´s that has the [type] = "Account" or "User" with Power Query or with a Dax function if you prefer. In this example Because [ID]="A" has both "Account" and "User" [type] I will only want the "B" [ID].
Thanks in advance
Solved! Go to Solution.
H @rmeng
So you want to remove the rows that have both "Account" AND "User", not OR. Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXJMTs4vzStRitWB8EOLU4vAHCdkyVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"type" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"type", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"type", each [type]}}),
res_ = Table.SelectRows(#"Grouped Rows", each not (List.Contains([type], "Account") and List.Contains([type], "User"))),
#"Removed Columns" = Table.RemoveColumns(res_,{"type"})
in
#"Removed Columns"
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any BI needs, tutoring, etc.
Cheers
Hi, @rmeng
my code as below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXJMTs4vzStRitWB8EOLU4vAHCdkyVgA", BinaryEncoding.Base64), Compression.Deflate)),{"ID","type"}),
selcRows = Table.SelectRows(Source,(row)=>not List.ContainsAll(Table.SelectRows(Source,each [ID]=row[ID])[type],{"Account","User"}))
in
selcRows
I have a similar scenario, however I have multiple values for type , like over 50. How do I achieve the same in my case ?
Hi, @rmeng
my code as below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXJMTs4vzStRitWB8EOLU4vAHCdkyVgA", BinaryEncoding.Base64), Compression.Deflate)),{"ID","type"}),
selcRows = Table.SelectRows(Source,(row)=>not List.ContainsAll(Table.SelectRows(Source,each [ID]=row[ID])[type],{"Account","User"}))
in
selcRows
H @rmeng
So you want to remove the rows that have both "Account" AND "User", not OR. Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXJMTs4vzStRitWB8EOLU4vAHCdkyVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"type" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"type", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"type", each [type]}}),
res_ = Table.SelectRows(#"Grouped Rows", each not (List.Contains([type], "Account") and List.Contains([type], "User"))),
#"Removed Columns" = Table.RemoveColumns(res_,{"type"})
in
#"Removed Columns"
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any BI needs, tutoring, etc.
Cheers
Hi, I have similar scenario . But the type column for my data has multiple data , like over 90 and the values are dynamic too, i.e., they might change over time. How I solve that ?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.