Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Morning all!
I would like to solve a problem with DAX. My requirements are as follows:
For each row in table A I would like to create two new columns:
In SQL it would be something like this:
select Sku from
tableA a Right outer join TableB b
On...
Where A.store = "X" and B.Rank = 1
Any ideas to start with?
Thank in you in advance!
Regards
Solved! Go to Solution.
You're essentially trying to perform a right outer join in DAX, which isn't as straightforward as SQL, but it's doable.
To achieve this, you can use the RELATEDTABLE and EXCEPT functions in DAX. Here's a rough idea of how you can approach this:
First, let's create a new table that filters TABLE B based on the FamilySku from TABLE A and excludes SKUs that are already in TABLE A:
FilteredTableB =
VAR CurrentFamilySku = SELECTEDVALUE('TABLE A'[FamilySku])
RETURN
FILTER(
EXCEPT(
FILTER('TABLE B', 'TABLE B'[FamilySku] = CurrentFamilySku),
FILTER('TABLE A', 'TABLE A'[FamilySku] = CurrentFamilySku)
),
'TABLE B'[Rank] <= 2
)
Now, let's create the two new columns in TABLE A:
For the first SKU:
FirstSKU =
VAR FilteredRows = FilteredTableB
RETURN
MINX(FILTER(FilteredRows, 'TABLE B'[Rank] = 1), 'TABLE B'[Sku])
For the second SKU:
SecondSKU =
VAR FilteredRows = FilteredTableB
RETURN
MINX(FILTER(FilteredRows, 'TABLE B'[Rank] = 2), 'TABLE B'[Sku])
These columns will give you the first and second SKUs from TABLE B that are not in TABLE A for the same FamilySku.
You're essentially trying to perform a right outer join in DAX, which isn't as straightforward as SQL, but it's doable.
To achieve this, you can use the RELATEDTABLE and EXCEPT functions in DAX. Here's a rough idea of how you can approach this:
First, let's create a new table that filters TABLE B based on the FamilySku from TABLE A and excludes SKUs that are already in TABLE A:
FilteredTableB =
VAR CurrentFamilySku = SELECTEDVALUE('TABLE A'[FamilySku])
RETURN
FILTER(
EXCEPT(
FILTER('TABLE B', 'TABLE B'[FamilySku] = CurrentFamilySku),
FILTER('TABLE A', 'TABLE A'[FamilySku] = CurrentFamilySku)
),
'TABLE B'[Rank] <= 2
)
Now, let's create the two new columns in TABLE A:
For the first SKU:
FirstSKU =
VAR FilteredRows = FilteredTableB
RETURN
MINX(FILTER(FilteredRows, 'TABLE B'[Rank] = 1), 'TABLE B'[Sku])
For the second SKU:
SecondSKU =
VAR FilteredRows = FilteredTableB
RETURN
MINX(FILTER(FilteredRows, 'TABLE B'[Rank] = 2), 'TABLE B'[Sku])
These columns will give you the first and second SKUs from TABLE B that are not in TABLE A for the same FamilySku.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 17 | |
| 8 | |
| 8 | |
| 7 |