Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Deeintu
Helper I
Helper I

How to write DAX to join two tables on multiple columns in Power bi?

Hi All,

I have data in 2 tables, I need to join these 2 tables on multiple columns by writing a DAX formula.

These 2 tables don't have connection or relationship in the data model. These are independent tables.

 

Also I don't want to merge these tables in Power query. My requirement is to achieve through DAX.

 

How can i get  Table 2 details along with corresponding sales values in Table 1 by joining on multiple columns.

 

Join conditions will be

Table1.Year =  Table2.Year
Table1.Category =  Table2.SubGroup
Table1.Region =  Table2.Location
Table1.Product =  Table2.Product

Table 1 data :

 

Deeintu_2-1646209501718.png

 

Table 2:

 

Deeintu_3-1646209626322.png

 

 

Expected result just showing few rows but ideally need to show  for all possible  rows.

Deeintu_1-1646209469969.png


Please see below links of  attached data and pbi files.

 

PBIX file:
https://www.dropbox.com/s/y9k3glcsmztxdqx/Sample%20File.pbix?dl=0

Table 1:
https://www.dropbox.com/scl/fi/33u4ma5hccjwq26w5b039/Sample-Table-1.xls?dl=0&rlkey=r3qvvq7rg8lr6preh...

Table 2:
https://www.dropbox.com/scl/fi/wcfz9vsttvmua3ghmil1o/Sample-Table-2.xls?dl=0&rlkey=206oaq0lnosh39dst...

 

Thanks in advance
Dee

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Deeintu 

you can try this

Column = maxx(FILTER('Table 1','Table 1'[Year]='Table 2'[Year]&&'Table 2'[Subgroup]='Table 1'[Category]&&'Table 1'[Location]='Table 2'[Location]&&'Table 1'[Product]='Table 2'[Product]),'Table 1'[Sales])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
ryan_mayu
Super User
Super User

@Deeintu 

you can try this

Column = maxx(FILTER('Table 1','Table 1'[Year]='Table 2'[Year]&&'Table 2'[Subgroup]='Table 1'[Category]&&'Table 1'[Location]='Table 2'[Location]&&'Table 1'[Product]='Table 2'[Product]),'Table 1'[Sales])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This isn't working for I have the same columns in two tables I have tried the formula with and without quotes

jimbobobwalker_0-1713285285630.png

With qoutes still give errors
 
Column = maxx(FILTER('RER_SUMMARY','RER_SUMMARY[Partner]'='OB_SUMMARY[Partner]'&&'RER_SUMMARY[FedACH ProcessDate]'='OB_SUMMARY[FedACH ProcessDate]'))

what's the error message? 

and you missed the second parameter.

https://learn.microsoft.com/zh-cn/previous-versions/sql/sql-server-2008-r2/ee634576(v=sql.105)?wt.mc...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Oh man didn't even see that, work great thank you.

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Great it worked.
Thanks @ryan_mayu 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




VijayP
Super User
Super User

@Deeintu 
you can use UNION Function 
Union ( 
Summarize (Table 1, required columns in speicific order),
Summarise ( Table 2, required columns same speicific order above)
Both Table columns order should be same




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.