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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
madisonb
Frequent Visitor

MAX function with multiple conditions for shape map

Hello,

 

I am creating a shape map with a color saturation of the highest incentives for each state. I am ranking some incentives as more valuable than others (rank column). I want to create a measure that calculates the max of [High] that prioritizes values labeled rank 1 first. If the value in [High] is not a rank 1, then the formula should calculate the max of [High] values with a rank 2 (...and so on up to a rank 5).
 
I was able to create a calculated column that returns the max [High] values based on the rank. But, I need to be able to do this through a measure to apply to my shape map. I have tested measures with nested IF statements as well as SWITCH TRUE, and cannot get it to calculate properly.  
 
Here is a sample of the data: Link 
 
Example Results: The map should show CO's max incentive as $2,400 with no filters. If I add a filter removing rank 1, the max incentive should update to $2,500. 
 
Hope this is possible!
 
1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @madisonb 

 

Please try this:
Here I create a measure for your reference:

MEASURE =
VAR _currentState =
    SELECTEDVALUE ( 'Table'[State] )
VAR _MinRank =
    CALCULATE (
        MIN ( 'Table'[Rank] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[State] = _currentState )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[High] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[State] = _currentState
                && 'Table'[Rank] = _MinRank
        )
    )

 The result is as follow:

vzhengdxumsft_0-1717036513457.pngvzhengdxumsft_1-1717036520075.png

 

Best Regards

Zhengdong Xu
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

2 REPLIES 2
v-zhengdxu-msft
Community Support
Community Support

Hi @madisonb 

 

Please try this:
Here I create a measure for your reference:

MEASURE =
VAR _currentState =
    SELECTEDVALUE ( 'Table'[State] )
VAR _MinRank =
    CALCULATE (
        MIN ( 'Table'[Rank] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[State] = _currentState )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[High] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[State] = _currentState
                && 'Table'[Rank] = _MinRank
        )
    )

 The result is as follow:

vzhengdxumsft_0-1717036513457.pngvzhengdxumsft_1-1717036520075.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-zhengdxu-msft 

 

This appears to be working perfectly! Thank you so much for your help!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.