Forum Discussion
Power Query Grouping and retaining other columns
- Mar 30, 2022
bartvana See attached.
Result2 is a UI only solution. No M-code edits required.
Result1 requires one small M-code edit. After grouping by the first three columns, merge the query with itself and edit the M-code from:
= Table.NestedJoin(#"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, #"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, "Grouped Rows", JoinKind.LeftOuter)
to:
= Table.NestedJoin(#"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, Source, {"Product", "Data1", "Data2", "Value"}, "Grouped Rows", JoinKind.LeftOuter)
All other steps are done by clicking and dragging in the UI.
bartvana See attached.
Result2 is a UI only solution. No M-code edits required.
Result1 requires one small M-code edit. After grouping by the first three columns, merge the query with itself and edit the M-code from:
= Table.NestedJoin(#"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, #"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, "Grouped Rows", JoinKind.LeftOuter)
to:
= Table.NestedJoin(#"Grouped Rows", {"Product", "Data1", "Data2", "Value"}, Source, {"Product", "Data1", "Data2", "Value"}, "Grouped Rows", JoinKind.LeftOuter)
All other steps are done by clicking and dragging in the UI.
- bartvanaMar 30, 2022Iron Contributor
Riny_van_Eekelen Perfect, thank you!