Find rows in lookup table that don't match any row in the data table

unire

New Member
Joined
Jul 29, 2016
Messages
3
What's the best way (preferably with DAX query functions, such as SUMMARIZE, GENERATE, etc) to find all the rows in a lookup table that have no matching row in the data table?

For example, with a data table like this:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Person ID
[/TD]
[TD]Country Key
[/TD]
[TD]Age
[/TD]
[/TR]
[TR]
[TD]581
[/TD]
[TD]1
[/TD]
[TD]25
[/TD]
[/TR]
[TR]
[TD]492
[/TD]
[TD]1
[/TD]
[TD]48
[/TD]
[/TR]
[TR]
[TD]390
[/TD]
[TD]2
[/TD]
[TD]37
[/TD]
[/TR]
[TR]
[TD]410
[/TD]
[TD]2
[/TD]
[TD]29
[/TD]
[/TR]
[TR]
[TD]173
[/TD]
[TD]2
[/TD]
[TD]61
[/TD]
[/TR]
</tbody>[/TABLE]

And this lookup table:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country Key
[/TD]
[TD]Country Name
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]United Kingdom
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Japan
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]China
[/TD]
[/TR]
</tbody>[/TABLE]

The query would need to return one row (3 - China).
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I think I figured it out.
To get all the rows in the lookup table that don't match any row in the data table, I'm doing this:

EVALUATE
FILTER(
DimCountries,
COUNTROWS(RELATEDTABLE(FactPeople)) = 0
)

And to do the other way around (data rows that don't match a lookup row):

EVALUATE
FILTER(
FactPeople,
RELATED(DimCountries[Country Key]) = BLANK()
)

But I don't know whether there are more efficient solutions.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top