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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Wadda7AboUdai
Helper I
Helper I

merge 3 tables in one table in dax

Hello everyone

 

I want to convert this code from sql to Dax

 

(SELECT T1.DIMENSIONATTRIBUTE, T1.ENTITYINSTANCE, T1.PARTITION
, T2.DISPLAYVALUE, T3.DIMENSIONATTRIBUTEVALUECOMBINATION AS VALUECOMBINATIONRECID
FROM DIMENSIONATTRIBUTEVALUE AS T1 INNER JOIN
DIMENSIONATTRIBUTELEVELVALUE AS T2 ON T1.RECID = T2.DIMENSIONATTRIBUTEVALUE AND T1.PARTITION = T2.PARTITION INNER JOIN
DIMENSIONATTRIBUTEVALUEGROUPCOMBINATION AS T3 ON T2.DIMENSIONATTRIBUTEVALUEGROUP = T3.DIMENSIONATTRIBUTEVALUEGROUP AND T2.PARTITION = T3.PARTITION
GROUP BY T1.DIMENSIONATTRIBUTE, T1.ENTITYINSTANCE, T1.PARTITION, T2.DISPLAYVALUE, T3.DIMENSIONATTRIBUTEVALUECOMBINATION

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Wadda7AboUdai ,

First use NATURALINNERJOIN or FILTER and RELATED to create a new table that represents the join between T1 and T2.

Step1_Result = 
NATURALINNERJOIN(
    DIMENSIONATTRIBUTEVALUE,
    DIMENSIONATTRIBUTELEVELVALUE
)

Then join the result with the third table T3.

Final_Result = 
NATURALINNERJOIN(
    Step1_Result,
    DIMENSIONATTRIBUTEVALUEGROUPCOMBINATION
)

Finally, use SELECTCOLUMNS to select the desired columns from the result of Step 2.

Merged_Table = 
SELECTCOLUMNS(
    Final_Result,
    "DIMENSIONATTRIBUTE", DIMENSIONATTRIBUTEVALUE[DIMENSIONATTRIBUTE],
    "ENTITYINSTANCE", DIMENSIONATTRIBUTEVALUE[ENTITYINSTANCE],
    "PARTITION", DIMENSIONATTRIBUTEVALUE[PARTITION],
    "DISPLAYVALUE", DIMENSIONATTRIBUTELEVELVALUE[DISPLAYVALUE],
    "VALUECOMBINATIONRECID", DIMENSIONATTRIBUTEVALUEGROUPCOMBINATION[DIMENSIONATTRIBUTEVALUECOMBINATION]
)

But please note that this is just directly written by me based on the SQL you provided, if it's not correct, please also provide me with sample data from your three data tables, thank you!

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Wadda7AboUdai ,

First use NATURALINNERJOIN or FILTER and RELATED to create a new table that represents the join between T1 and T2.

Step1_Result = 
NATURALINNERJOIN(
    DIMENSIONATTRIBUTEVALUE,
    DIMENSIONATTRIBUTELEVELVALUE
)

Then join the result with the third table T3.

Final_Result = 
NATURALINNERJOIN(
    Step1_Result,
    DIMENSIONATTRIBUTEVALUEGROUPCOMBINATION
)

Finally, use SELECTCOLUMNS to select the desired columns from the result of Step 2.

Merged_Table = 
SELECTCOLUMNS(
    Final_Result,
    "DIMENSIONATTRIBUTE", DIMENSIONATTRIBUTEVALUE[DIMENSIONATTRIBUTE],
    "ENTITYINSTANCE", DIMENSIONATTRIBUTEVALUE[ENTITYINSTANCE],
    "PARTITION", DIMENSIONATTRIBUTEVALUE[PARTITION],
    "DISPLAYVALUE", DIMENSIONATTRIBUTELEVELVALUE[DISPLAYVALUE],
    "VALUECOMBINATIONRECID", DIMENSIONATTRIBUTEVALUEGROUPCOMBINATION[DIMENSIONATTRIBUTEVALUECOMBINATION]
)

But please note that this is just directly written by me based on the SQL you provided, if it's not correct, please also provide me with sample data from your three data tables, thank you!

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.