Forum Discussion
POWERBI: Join tables through the same column
I have two tables with the same columns and I want to make a union between them, so that I get a table in which I have only the products_id that match each other.
Simplifying my case and omitting the rest of the columns:
TABLE 1
Product_id
1
2
2
2
TABLE 2
Product_id
1
1
3
4
The result I want to achieve in this case would be as follows:
TOTAL TABLE
Product_id
1
1
1
2
2
2
I have tried to use the FUNCTIONS of UNION and INTERSECT, but with none I have obtained the result I expected. I'm new to DAX language so I may have done it wrong. Thanks a lot!!
Hey,
Based on your example, this function should provide the desired result:
TOTAL TABLE = UNION ( TABLE1, INTERSECT ( TABLE2, TABLE1 ) )Result:
4 Replies
- Barthel
Solution Sage
Hey,
Based on your example, this function should provide the desired result:
TOTAL TABLE = UNION ( TABLE1, INTERSECT ( TABLE2, TABLE1 ) )Result:
- bcdobbs
Community Champion
Depending on how everything else is setup is generally better to do what you asking in Power Query (Transform Data). Using "Append Query": Append queries (Power Query) (microsoft.com)
- SpartaBI
Community Champion
Syndicate_Admin wirte this calculated table:
Total Table = VAR _values = INTERSECT(VALUES('TABLE 1'[Product_id]), VALUES('TABLE 2'[Product_id])) VAR _result = UNION( FILTER( 'TABLE 1', 'TABLE 1'[Product_id] IN _values ), FILTER( 'TABLE 2', 'TABLE 2'[Product_id] IN _values ) ) RETURN _result
In case it answered your question, please accept the solution to help other members find it. Appreciate Your Kudos.
SpartaBI Logo
Visit SpartaBI website Visit SpartaBI Linkdin Visit SpartaBI Facebook
Showcase Report – Contoso By SpartaBI - v-henryk-mstf
Community Support
Hi Syndicate_Admin ,
Table merging can be achieved both through the append function in power query and by creating dax formulas in powerbi.
Refer to the solution given by Barthel SpartaBI for details.If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Looking forward to your feedback.
Best Regards,
Henry