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
YC
Frequent Visitor

Help on MAX formula

Hello! I am trying to create a measure or a column to calculate the max value by material and by region, as per below example. 

Basically, if I will not filter anything on region, I want to see Max by material only, if I filter region I want to see max by material & region.

 

RegionMaterialPriceMax price (per material/per region)Max price (per material)
Europematerial A335
NAmaterial A555
LAmaterial A225
Europematerial A135
Europematerial B94598
Europematerial B454598
Asiamaterial B2298
NAmaterial B989898
NAmaterial B139898

 

I managed to calculate it separately (by material, and separate by region), using this formula:

CALCULATE(MAX('Dataset'[Price]), FILTER(ALLSELECTED('Dataset'),'Dataset'[Material]=EARLIER('Dataset'[Material])))
 
But I need to have it done based on both criteria so that I can show the correct value when filtering a certain region. 
 
Can someone please guide me on what is the correct formula to obtain this?
 
Thank you!
1 ACCEPTED SOLUTION

I have updated the formula in the same comment. Please double check and let me know what results you get?

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @YC 
Please try 

 

 

Max price (per material) =
CALCULATE (
    MAX ( 'Dataset'[Price] ),
    ALLEXCEPT ( 'Dataset', 'Dataset'[Material], 'Dataset'[Rgion] )
)

 

 

YC
Frequent Visitor

Hello! Thank you very much for the formula. This is working to show max per material indeed, but if I would filter a certain region, will not give the correct result.

YC_0-1652770740763.png

 

I have updated the formula in the same comment. Please double check and let me know what results you get?

YC
Frequent Visitor

With second field changed to region worked perfectly fine. Thank you very much for the help!!

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.

Top Solution Authors