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,
Is there any feature in Power BI making it possible to merge quickly various tables with a left join ?
Example
Table A contains [ID] and [Field_1]
Table B contains [ID] and [Field_2]
Table C contains [ID] and [Field_3]
Table D contains [ID] and [Field_4]
Table E contains [ID] and [Field_5]
I want a table F containing those [ID] and the 5 fields.
At the moment I know only one solution: Merge A and B into a first table, then merge this new table with C, and then with D and then with E.
Thanks.
Solved! Go to Solution.
There might be an easier solution to this, but this is all I can come up with currently:
let TableA = #table({"ID", "Column1"}, {{"A", 10}, {"B", 20}}), TableB = #table({"ID", "Column2"}, {{"A", 100}, {"B", 200}}), TableC = #table({"ID", "Column3"}, {{"A", 1000}, {"B", 2000}}), ListOfTables = {TableA, TableB, TableC}, DynamicLeftOuterJoin = List.Accumulate(List.Skip(ListOfTables,1), [x = ListOfTables{0}, Counter=0], (state, current) => [x = let Join = Table.NestedJoin(state[x],{"ID"},current,{"ID"},"Result" & Text.From(state[Counter]),JoinKind.LeftOuter), Expand = Table.ExpandTableColumn(Join, "Result" & Text.From(state[Counter]), {List.Difference(Table.ColumnNames(current), {"ID"}){0}} ) in Expand, Counter = state[Counter]+1])[x] in DynamicLeftOuterJoin
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
There might be an easier solution to this, but this is all I can come up with currently:
let TableA = #table({"ID", "Column1"}, {{"A", 10}, {"B", 20}}), TableB = #table({"ID", "Column2"}, {{"A", 100}, {"B", 200}}), TableC = #table({"ID", "Column3"}, {{"A", 1000}, {"B", 2000}}), ListOfTables = {TableA, TableB, TableC}, DynamicLeftOuterJoin = List.Accumulate(List.Skip(ListOfTables,1), [x = ListOfTables{0}, Counter=0], (state, current) => [x = let Join = Table.NestedJoin(state[x],{"ID"},current,{"ID"},"Result" & Text.From(state[Counter]),JoinKind.LeftOuter), Expand = Table.ExpandTableColumn(Join, "Result" & Text.From(state[Counter]), {List.Difference(Table.ColumnNames(current), {"ID"}){0}} ) in Expand, Counter = state[Counter]+1])[x] in DynamicLeftOuterJoin
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
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 |
---|---|
107 | |
93 | |
77 | |
65 | |
53 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |