Forum Discussion
jose_cruzrodz
3 years agoFrequent Visitor
Filter records by second column, based on primary column answer
Greetings, Here is my sample data: Expected result: What I need to accomplish is look at Column E first. If that column has a value of "Yes", then I look at Col...
- 3 years ago
First thing that comes to my head is this..
Duplicate the Table and remove all but columns B and E and filter it to just "Yes"Then, merge this table back to your main table using column B
Expand column E(from table 2) and rename it to make it a little more clear.
Use this new column and only filter for "Yes"
Vijay_A_Verma
3 years agoMost Valuable Professional
Insert this code where #"Changed Type" should be replaced with your previous step
= Table.Combine(List.Select(Table.Group(#"Changed Type", {"ColumnB"}, {{"All", each _}})[All], (x)=>List.Contains(x[ColumnE], "Yes")))
Complete test code in action for testing
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk8sSS1S0lEyNDIGksGlxYl5QDo7JSs7BUgrxeoglJiYmoGUlKSWpQLptNTUwtRCmJrgxLwUAkoIGBOZWoyizNzCEkg65iWCFKWkpaDZhCqdkoZkQmJeZUlGZl46LkNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t, ColumnB = _t, ColumnC = _t, ColumnD = _t, ColumnE = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ColumnA", type text}, {"ColumnB", Int64.Type}, {"ColumnC", type text}, {"ColumnD", type text}, {"ColumnE", type text}}),
#"Grouped Rows" = Table.Combine(List.Select(Table.Group(#"Changed Type", {"ColumnB"}, {{"All", each _}})[All], (x)=>List.Contains(x[ColumnE], "Yes")))
in
#"Grouped Rows"