Forum Discussion

jeronimo2334's avatar
jeronimo2334
Helper III
5 years ago
Solved

Joining tables on multiple date columns

Hello,   I have table1 and table2 and I'm hoping to get table3 as a result. https://www.dropbox.com/sh/wn450alvxn6kja5/AACsmmOXBXs94pXtbDxoyFs_a?dl=0 Some information on how this calculation is...
  • parry2k's avatar
    5 years ago

    jeronimo2334 here is the DAX expression, add as a new column. I didn't create the relationship between the tables to avoid "many to many" but that can be used too:

     

    Name = 
    VAR __id = table2[id]
    VAR __post = table2[datePosted]
    VAR __relatedTable = CALCULATETABLE ( table1, TREATAS ( { __id } ,  table1[id] ) )
    VAR __names = 
    CALCULATETABLE ( 
        VALUES ( table1[givenName] ), 
        TREATAS ( { __id }, table1[id] ),  
        table1[crStart] <= __post , 
        ( table1[crThru] == BLANK() || table1[crThru] >= __post  ),
        table1[cLStart] <= __post , 
        ( table1[cLThru] == BLANK() || table1[cLThru] >= __post  ),
        table1[opiStart] <= __post , 
        ( table1[opiThru] == BLANK() || table1[opiThru] >= __post  ),
        table1[piStart] <= __post , 
        ( table1[piThru] == BLANK() || table1[piThru] >= __post  ),
        table1[uiStart] <= __post , 
        ( table1[uiThru] == BLANK() || table1[uiThru] >= __post  ) 
    )
    
    RETURN
    CONCATENATEX (
        __names,
        [givenName], "," 
    )

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.