Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Noeleke1301
Helper III
Helper III

Lookup with wildcards (sequential lookup)

Hi all,

 

I'm trying to solve the following problem. I have a main table with values in each column. I want to look up an Id from another table.

 

UnitDebtorLocationId
AABCDAMS(should be 14)
BABCDQUE(should be 12)
CABCDAMS(should be 14)

 

The other table contains Id's with condition columns. However, some of these values are blank, which mean they act as a wildcard/fallback.

 

IdDebtorLocationAmount
12ABCD 30
14ABCDAMS40

 

If I use an OR operator || , like main[location] = lookup[location] || ISBLANK( main[location] ), it always returns Id 14 because it will always find a match with the blank [location], and thus returns Id 14.

 

How can I make this check sequential? So only check the next condition if it doesn't find an exact match first? So in this case, first check the whole lookup table if there's a specific row with [location] AMS, if not then check for blank [location]

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Id =
var d = [Debtor]
var l = [Location]
var f = filter(Table2,[Debtor]=d && coalesce([Location],l)=l)
return if(countrows(f)>0,maxx(f,[Id]))
 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Id =
var d = [Debtor]
var l = [Location]
var f = filter(Table2,[Debtor]=d && coalesce([Location],l)=l)
return if(countrows(f)>0,maxx(f,[Id]))
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.