Forum Discussion
Merging two asymmetrical tables
- 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
Ah amazing thank you, I will try that and let you know how I get on. Will that method work if both input tables are Dax generated, not imported?
No, in that scenario you need to create a composite key [max date]+[project key] in both tables and then join via that composite key.