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
Anonymous
Not applicable

Join columns from two unrelated tables based on multiple common columns in DAX

Hi team,

I need to implement below requirement in DAX.

I have two tables like below. Both the tables are not related to each other and they are not related to any common tables(Sample tables below)

Table 1                                                         

pdtcstAcv
P1C10.1
P2C21.1
P3C32.1
P4C43.1
P5C54.1

Table 2

pdtcsttgt
P1C12.2
P2C23.2
P3C34.2
P4C45.2
P5C56.2

The tables have multiple common columns.I want to create a calculated table which will have the columns from two tables which are joined based on the multiple common columns between them something like below(Similar to inner join in SQL)

pdtcstAcvtgt
P1C10.12.2
P2C21.13.2
P3C32.14.2
P4C43.15.2
P5C54.16.2

The join should be based on both pdt and cst columns.

I tried using Summarize with Union and Treatas options but no luck.

Can this be done.Please suggest.

 

Thanks,

Sam

4 REPLIES 4
Anonymous
Not applicable

Thanks for taking time to reply @V-pazhen-msft / @amitchandak . I used treatas with NaturalInnerJoin and it worked.

 

Thanks,

Sam

V-pazhen-msft
Community Support
Community Support

@Anonymous 

Is there any reason you cannot not have an active relationship between the tables. You could create this relationship between the [pdt] columns and leave it as Inactive relationship (dotted line). Then create the following measure:

 

Measure = CALCULATE(SUM('Table (2)'[tgt]),USERELATIONSHIP('Table'[pdt],'Table (2)'[pdt]),FILTER('Table (2)',[pdt]=MAX('Table'[pdt])))

 

use relationship measure.JPG

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , you can create one/two common dimensions of pdt and cst. and join with both the tables and analyze them.

 

If need you can create a combine key.

Key = [pdt] & "-" & [cst]

 

refer

https://www.knowledgehut.com/blog/business-intelligence-and-visualization/power-bi-best-practices

Anonymous
Not applicable

@amitchandak ..I have many columns in actual tables and I cannot create new tables.Also I dont have any of these columns in the visual, but I require these columns in one table to perform further analysis. 

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.