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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Raphael33
New Member

Join 2 tables

Hello all,

 

I created a DAX table in which I created 2 variables, with which I get the data from 2 different tables.

 

I want to join these 2 tables in only one. I tried with UNION (but I don't have the same amount of columns in the 2 tables), et NATTURALLEFTOUTERJOIN (but it doesn't work). Could someone help please ? Here's my code below :

T04_MDPF_CDC V2 =

var MDPF71 =
    SELECTCOLUMNS(
        T03_SKU_Country_List,
        "Affaire Planning Mode",
        LOOKUPVALUE('02_Ref_Affaires'[Planning_mode],'02_Ref_Affaires'[CDC_Location],[CDC Code Destination],BLANK()),
        "Affaire Name",
        LOOKUPVALUE('02_Ref_Affaires'[Title],'02_Ref_Affaires'[CDC_Location],[CDC Code Destination],BLANK()),
        "Material Code",
        var SubGrpAgg =
        SUMMARIZE(
            FILTER(
                S08_Z632_MatTransferAgg,
                T03_SKU_Country_List[Material Code] = S08_Z632_MatTransferAgg[Material Code]
            ),
            [SubGrpAgg]
        )
        RETURN SubGrpAgg
    )

var Launch_Intro_Table =
    SELECTCOLUMNS(
        FILTER(
            S01_Launch_Intro,
            (S01_Launch_Intro[Product Code] & S01_Launch_Intro[Network Entity Destination Code]) IN SELECTCOLUMNS(T03_SKU_Country_List, "Key_SKU_CDC", T03_SKU_Country_List[Key_SKU_CDC])
        ),
        "Material Code", [Product Code],
        "Project Code", [Project Code],
        "Launch Intro Status", [Final Launch Intro Status],
        "LI_15M", [LI_15M],
        "One Shot", [One Shot],
        "Flag LI Futur", [Flag LI Futur],
        "LI Final Product IDC Availability", [Final Product IDC Availability],
        "LI Final IDC Closing Date", [Final IDC Closing Date]
    )

var FirstJoinTable =
    UNION(
        Launch_Intro_Table,
        MDPF71
    )

RETURN
FirstJoinTable
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Raphael33 Assuming that the relationship between the 2 tables is Material Code, perhaps this as your "join" VAR:

var FirstJoinTable =
    ADDCOLUMNS(
        Launch_Intro_Table,
        "Affaire Planning Mode",
            VAR __MaterialCode = [Material Code]
            VAR __Result = MAXX( FILTER( MDPF71, [Material Code] = __MaterialCode), [Affaire Planning Mode" )
        RETURN
            __Result
        "Affaire Name",
            VAR __MaterialCode = [Material Code]
            VAR __Result = MAXX( FILTER( MDPF71, [Material Code] = __MaterialCode), [Affaire Name" )
        RETURN
            __Result
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@Raphael33 Assuming that the relationship between the 2 tables is Material Code, perhaps this as your "join" VAR:

var FirstJoinTable =
    ADDCOLUMNS(
        Launch_Intro_Table,
        "Affaire Planning Mode",
            VAR __MaterialCode = [Material Code]
            VAR __Result = MAXX( FILTER( MDPF71, [Material Code] = __MaterialCode), [Affaire Planning Mode" )
        RETURN
            __Result
        "Affaire Name",
            VAR __MaterialCode = [Material Code]
            VAR __Result = MAXX( FILTER( MDPF71, [Material Code] = __MaterialCode), [Affaire Name" )
        RETURN
            __Result
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors