cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MichaelHawley New Member
New Member

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
Community Support Team
Community Support Team

Re: Lookup first value in a table with varying levels of specificity

@MichaelHawley ,

 

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
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 353 members 3,244 guests
Please welcome our newest community members: