Forum Discussion

wlknsnBI's avatar
wlknsnBI
Helper II
6 years ago
Solved

Joining Tables multiple Keys in DAX

Hi,

 

I'm looking for the following join of tables based on multiple keys, preferrably in DAX (not power query):

 

 

So based on GROUP & TYPE for each LINE, PRODUCT is joined.

 

  • Hi wlknsnBI 

     

    If you are looking to output a table then Power Query would be more efficient.

    If you are looking to create a relationship between these two tables then you can concatenate these two columns and later create a relationship.
    If you just need it for a Measure you can use TREATS 

    if you need to calculate a table then you can use this code.

    Table = 
    GENERATE(
        Table1,
        VAR __group = Table1[Group]
        VAR __type = Table1[Type]
        RETURN 
        SELECTCOLUMNS(
            FILTER( 
                Table2,
                Table2[Group] = __group 
                && Table2[Type] = __type
            ),
            "Line", Table2[Line]
        )
    )

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn

     

     

2 Replies

  • Mariusz's avatar
    Mariusz
    Community Champion

    Hi wlknsnBI 

     

    If you are looking to output a table then Power Query would be more efficient.

    If you are looking to create a relationship between these two tables then you can concatenate these two columns and later create a relationship.
    If you just need it for a Measure you can use TREATS 

    if you need to calculate a table then you can use this code.

    Table = 
    GENERATE(
        Table1,
        VAR __group = Table1[Group]
        VAR __type = Table1[Type]
        RETURN 
        SELECTCOLUMNS(
            FILTER( 
                Table2,
                Table2[Group] = __group 
                && Table2[Type] = __type
            ),
            "Line", Table2[Line]
        )
    )

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn