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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Lookup first value in a table with varying levels of specificity

Hi there datanauts,

I have a very hard question that has consumed many hours.  

 

I have table of values (~10,000).

I need to get one corresponding value from a lookup table. 

 

The looktable has a series of values for each scenario with differing levels of specificity. 

I.e there will be:

A general value for Jim

There might also be:

A rule if Jim and Origin = "NZ"

And an even more specific rule for:

If  Jim and NZ and product number is between 330 and 450

 

I actually have about 5 levels of specifity in the rules. 

 

In this example, I would need to look up a product of:

Name: Apple,   Picked: Jim, Origin: NZ  Product Number:  441.

If a value can't be found with the exact requirements, it should drop the product number and try again, then the origin and try again, then the picked and try again. 

 

I could achieve this with a series of merges.  I can do my dataset in 6 merges (when I filter down the dataset) but with the size of the full dataset it's taking hours to calculate.  

 

I've also tried sorting my table from most specific rules to least specific then writing a function to get the lookup table, filter by each specification (e.g, Origin = "NZ or Origin = "Blank"), then use list.first to bring back the top result.  This works and is marginally faster but still can't handle the entire dataset. 

 

I've also taken to shrinking my lookup table first to ensure if only has values and are included in the data.

 

I feel like there's an easy solution somewhere.  Can I use wildcards in powerbi then only bring back the first result it finds?

 

Any help is much much appeciated,

Mike  

 

Main Table

Main Table.png

 

Lookup Table.png

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may also try DAX.

https://community.powerbi.com/t5/Desktop/Lookup-Price-Range-for-Style/m-p/322514#M143719

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.