Forum Discussion
Join tables based on multiple columns
- 8 years ago
Hey,
in the query editor
- duplicate the columns that you want to use for the join
- mark the duplicated columns you want to use for the join, choose "Merge columns" from the context menu.
Here is a screenshot:
Repeat this for the 2nd table.
Now you are able to use this column to create a relationship between both tables
Don't forget to "hide" this column from report view.
Hopefully this answers your question
Regards
Tom
TomMartens: Thanks for the reply. I did not understand it completely. Could you give me example and tell me how the output would look? Will the concatenated column have unique values?
Sorry I am new to this.
Hey,
in the query editor
- duplicate the columns that you want to use for the join
- mark the duplicated columns you want to use for the join, choose "Merge columns" from the context menu.
Here is a screenshot:
Repeat this for the 2nd table.
Now you are able to use this column to create a relationship between both tables
Don't forget to "hide" this column from report view.
Hopefully this answers your question
Regards
Tom
- alfmos7 years agoNew Member
What if in the two columns merged there are values 1 and 11, and the same in the columns merged in the second table? There will be an incorrect join for 1-11 and 11-1.
- LON6 years agoHelper I
You can do this in Power Query with Table.Join or Table.NestedJoin; as they are, these functions will join on a single column only; you can circumvent this, by replacing the Table parameters with Table.AddColumn, which can add - on the fly - a new, composite column, to join on, something like:
JoinedTable = Table.NestedJoin(Table.AddColumn(Table1, "CompositeColumn1", each [JoinColumn1] & [JoinColumn2]), "CompositeColumn1", Table.AddColumn(Table2, "CompositeColumn2", each [JoinColumn1] & [JoinColumn2]), "CompositeColumn2", "NewCompositeColumn"),
- Anonymous6 years agoNot applicable
Hi LON Thanks for the feedback, must admit I'd forgotten all about this, mainly because I'd worked around it, doing something similar to what you describe, using a DAX formula.
Regards
Fred
- JChaves3 years agoNew Member
This is new for me, and works perfectly!
Tks
- KTyler2 years agoFrequent Visitor
OMG this was the reason I advocated for PBI, and now it's no better than any other tool. Way to go MS, for taking away the one reason PBI stood apart.
- Anonymous8 years agoNot applicable
TomMartens: I am now able to create a relationship between the 2 tables but somehow the filtering is still not working. Any ideas?
- gujames8 years agoNew Member
I'm having a similar issue.
I'm trying to merge together the tables so that Ican use two layers in a ArcGIS Map in PowerBI.
Data is broken out per the below:
Table 1: Brand Index
Col1 - Brand
Col2 - Index
Col3 - Latitude
Col4 - Longitude
Table 2: Brand Locations
Col1 - Brand
Col2 - Latitude
Col3 - Longitude
I'd like to merge the datasets so that the result shows:
Col1- Brand
Col2- Type (Index vs Location)
Col3- Index
Col4- Latitude
Col5- Longitude
But when I try to merge the datasets, or append them, I end up with two columns for Latitude and 2 columsn for Longitude. Any advise here would be greatly appreciated.
- bscholesboogie7 years agoRegular Visitor
Unfortunately, this method doesn't work if your input tables are in DirectQuery mode. When you try to merge, you'll get an error message and an option to transform the data input to Input mode.
- Anonymous7 years agoNot applicable
So, new to Power BI but this is something I'm trying to achieve, using MSProject as input. How can I tell if the tables are "in DirectQuery mode" and how do you "duplicate" columns, is it simply a matter of adding a New Column and setting the formula to “DupCol = Col-I-want-to-join”
- dchapman3747 years agoRegular Visitor
What an excellent idea!
- pwc_ananta4 years agoHelper I
TomMartens
Thanks for guiding.
Can you please tell me how will we design Incremental load with Merged Query.
In my case, I have to join tables with outer joins, I can't done it with concatenation, If I join the tables in merge query, than how I manage the Last_Updated_Date.
Should I create the Reference of tables and than merge the referenced queries using merge query and configure the incremental load on the original loaded tables?
What is the correct way to do it? - JustSayJoe3 years agoAdvocate IV
Could you please confirm whether or not you can use these steps with a Calculated Column? It doesn't look like on my end, but maybe I'm missing a step.
- sboobar3 years agoFrequent Visitor
This worked great for me, thank you!
- Kiwi_Mark_LFC1 year agoFrequent Visitor
Or you could use INSERT MERGED COLUMNS