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

How to find the nearest match and value against that

Hi Everyone,

I am new to the Power BI and Stuck in a situation. I need to find the price of the pack nearest to the filter, if exact pack size is not available.

I have attached the sample data in which I need to find the minimum price from all the countries. If two records are available for single country we need to find the nearest one on the basis of pack size and than basis the full list we need to find the minimum price.

 

I have mentioned the criteria below.

Data Table.pngFilter Criteria.png

 

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Please kindly check below results:

Flag_1 = 
var a = 
CALCULATE(MIN(Data[Abs_size]),ALLEXCEPT(Data,Data[Country]))
return
IF(Data[Abs_size]=a&&Data[Flag]=1,1,0)
Measure 2 = 
IF(SELECTEDVALUE('HO Status'[HO Status])="Include HO",1,IF(SELECTEDVALUE(Data[HS Status])<>"HO",1,0))
Measure 3 = CALCULATE(MIN(Data[Unit_Price]),FILTER(Data,Data[Flag_1]=1&&[Measure 2]=1))*10

6.PNG

Pbix attached.

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

View solution in original post

5 REPLIES 5
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Please kindly check below results:

Flag_1 = 
var a = 
CALCULATE(MIN(Data[Abs_size]),ALLEXCEPT(Data,Data[Country]))
return
IF(Data[Abs_size]=a&&Data[Flag]=1,1,0)
Measure 2 = 
IF(SELECTEDVALUE('HO Status'[HO Status])="Include HO",1,IF(SELECTEDVALUE(Data[HS Status])<>"HO",1,0))
Measure 3 = CALCULATE(MIN(Data[Unit_Price]),FILTER(Data,Data[Flag_1]=1&&[Measure 2]=1))*10

6.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Hi Team,

Thank you soo much for your support on this. This is exactly what I am looking for.

I have one last question, how i can calculate average of 3 lowest price insted of minimum price is attached pbix file?

Abhik

v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

you might consider creating pbix file that will contain some sample data (remove the confidential info), upload the pbix to onedrive or dropbox and share the link to the file. Please do not forget to describe the expected results based on this sample data.

 

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Sample data as text please.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

I have added the file link below for your reference.Link 

 

Best Regards,

Abhik

 

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.