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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.