Forum Discussion

chipchidster's avatar
chipchidster
Resolver I
2 years ago
Solved

Merging two asymmetrical tables

I am sure I am being thick here, and I realise that my data is probably not in the best shape to acheive this but....   I am trying to combine two tables into a single data table within PBI.  Each ...
  • chipchidster's avatar
    1 year ago

    Okay, so after much bang of my head against a DAX shaped brick wall, and using the helpful suggestions by lbendlin I have managed to get closer to what I was looking for.  In the end I used the followign approach:

     

    I defined two tables using SUMMARIZE and SELECTCOLUMNS, then using NATURALLEFTOUTERJOIN to join them together.  One thing to note was, data lineage meant that my join kept failing.  I got around this by appending a 0 to the key value being used to join tables - this broke the lineage and allowed the join to work.  I've included the code below in case it helps people to understand the approach.

     

     

    var tableA = SELECTCOLUMNS(SUMMARIZE(sprint,
                                         sprint[squad_sprint],
                                         sprint[sprint_id],
                                         sprint[name]),
                              "squad_sprint", [squad_sprint]&"0",
                              "sprint_id", [sprint_id],
                              [name])
    
    var tableB = SELECTCOLUMNS(SUMMARIZE(history_sprint_summary,
                                         history_sprint_summary[squad_sprint],
                                         history_sprint_summary[project_key],
                                         history_sprint_summary[max_sprint_date]),
                           "squad_sprint", [squad_sprint]&"0",
                           "project_key", [project_key],
                           "max_sprint_date",[max_sprint_date])
    var result = NATURALLEFTOUTERJOIN(tableB, tableA)
    RETURN result