Forum Discussion

YC's avatar
YC
Frequent Visitor
4 years ago
Solved

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!
  • I have updated the formula in the same comment. Please double check and let me know what results you get?

4 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi YC 
    Please try 

     

     

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

     

     

    • YC's avatar
      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.

       

      • tamerj1's avatar
        tamerj1
        Community Champion

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