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.
Sorry for the titlegore! Here's the situation:
I want to start with something like this:
TableType | TableColumn |
1 | Table |
1 | Table |
2 | Table |
2 | Table |
2 | Table |
3 | Table |
3 | Table |
And my desired result is this:
TableType | JoinedTableColumn |
1 | Table |
2 | Table |
3 | Table |
...Where the final tables are joined 1+1, 2+2+2, 3+3.
My instinct says iterate through the list, if [TableType]{Counter} = [TableType]{Counter-1} then join Table to previous Table, else Table. The problem is if I use something like List.Generate, I don't have a way of storing previous table from the last run-through?
Again, very new to M. Any thoughts are appreciated, thanks!
Solved! Go to Solution.
@WolfBiber isn't Power Query the part before the datamodel?
Below 2 queries and a video to show how it looks like. Tables are joined and expanded.
Remark: the tables that are joined, must have different column names (except for "PrimaryKey").
Should you have further requirements, please provide a link to a file with representative test data.
Query Start:
let Source = #table(type table[TableType = number,TableColumn = table,joinKind = number], {{1,Table1,null}, {1,Table2,JoinKind.Inner}, {2,Table3,null}, {2,Table4,JoinKind.FullOuter}, {2,Table5,JoinKind.FullOuter}, {3,Table6,null}, {3,Table7,JoinKind.FullOuter}}) in Source
Query Result:
let Source = Table.Buffer(Start), JoinTables = (Table as table) as table => let RemovedTableType = Table.RemoveColumns(Table,{"TableType"}), TableRows = Table.ToRows(RemovedTableType), JoinTables = List.Accumulate(List.Skip(TableRows),TableRows{0}{0},(jt,t) => let Joined = Table.NestedJoin(jt,{"PrimaryKey"},t{0},{"PrimaryKey"},"JoinedTableColumn",t{1}), ColumnNames = List.Difference(Table.ColumnNames(t{0}),{"PrimaryKey"}), Expanded = Table.ExpandTableColumn(Joined,"JoinedTableColumn",ColumnNames) in Expanded) in JoinTables, #"Grouped Rows" = Table.Group(Source, {"TableType"}, {{"AllRows", JoinTables, type table}}) in #"Grouped Rows"
Video:
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.
User | Count |
---|---|
108 | |
105 | |
88 | |
74 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |