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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
eliabreupr
Frequent Visitor

Conditional formatting by matrix segment

Hi, I have a matrix table that has a segment with each employee under that segment. I need each segment to identify the max value ( the person with the highest number) with conditional formatting to highlight the value. 

 

I have tried everything but keep only coloring the highest value overall in the column, not by segment. Below are the two dax, I have had tried

 

Dax 1

Rank = VAR HighestValue = MAXX(ALLSELECTED('table'[Segment], 'table'handlername), [Promoter Count])

RETURN

IF ([Promoter Count]= HighestValue, "Red")

 

Dax 2

Rank = VAR HighestValue = MAXX(ALL(table'segment, 'table'hnadler name), [Promoter Count])

 

RETURN

SWITCH( 

   TRUE(),

   MAX('20220421072842-SurveyExport'[Segment]) = "AMD" && [Promoter Count] = HighestValue, "blue",

   MAX('20220421072842-SurveyExport'[Segment]) = "Property" && [Promoter Count] = HighestValue, "Yellow",

   MAX('20220421072842-SurveyExport'[Segment]) = "Liability" && [Promoter Count] = HighestValue, "Red",

   MAX('20220421072842-SurveyExport'[Segment]) = "WC" && [Promoter Count] = HighestValue, "orange")

 

 

 

 

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @eliabreupr ,

I have created a simple sample, please refer to it to see if it helps you.

Create two measures.

Measure =
VAR _maxvalue =
    MAXX (
        FILTER (
            ALL ( 'table' ),
            'table'[Segment] = SELECTEDVALUE ( 'table'[Segment] )
        ),
        [Promoter CountME]
    )
RETURN
    IF ( 'table'[Promoter CountME] = _maxvalue, "Red", BLANK () )
Rank_a =
VAR HighestValue =
    MAXX (
        FILTER (
            ALL ( 'table' ),
            'table'[Segment] = SELECTEDVALUE ( 'table'[Segment] )
        ),
        [Promoter CountME]
    )
RETURN
    SWITCH (
        TRUE (),
        MAX ( 'table'[Segment] ) = "AMD"
            && [Promoter CountME] = HighestValue, "blue",
        MAX ( 'table'[Segment] ) = "Property"
            && [Promoter CountME] = HighestValue, "Yellow",
        MAX ( 'table'[Segment] ) = "Liability"
            && [Promoter CountME] = HighestValue, "Red",
        MAX ( 'table'[Segment] ) = "WC"
            && [Promoter CountME] = HighestValue, "orange"
    )

vpollymsft_0-1657523028954.png

How to Get Your Question Answered Quickly 

 

If I have misunderstood your meaning, please provide more details with your desired output and pbix file without privacy information.

 

 Best Regards
Community Support Team _ Polly

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

 

Hi! This is close to what I need. For some reason, instead of pointing out the highest value is pointing the lowest when I used the recommended dax. Any idea of why?

 

Probably because my table under each segment has the employee? 

eliabreupr_4-1657545999299.png

 

eliabreupr_5-1657545999102.png

 

 

 

eliabreupr_3-1657545955127.png

 

Anonymous
Not applicable

Hi @eliabreupr ,

Please check the  measure [Promoter Count].  How did you write your formula?  Please return the HighestValue. Check if this formula returns the maximum value.

 

Rank_a = VAR HighestValue = MAXX(filter(ALL('table'), 'table'[Segment]=SELECTEDVALUE('table'[Segment])), [Promoter CountME])

 

RETURN HighestValue

//SWITCH( TRUE(), MAX('table'[Segment]) = "AMD" && [Promoter CountME] = HighestValue, "blue",MAX('table'[Segment]) = "Property" &&[Promoter CountME] = HighestValue, "Yellow",MAX('table'[Segment]) = "Liability" && [Promoter CountME] = HighestValue, "Red", MAX('table'[Segment]) = "WC" && [Promoter CountME] = HighestValue, "orange")

vpollymsft_0-1657587955185.png

 

 

  

Please provide more screenshots with measure [Promoter Count] and the return value.

 

Best Regards
Community Support Team _ Polly

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

I noticed that my table structure has segments and employees under each segment, like a matrix summary. It is different from the sample table that you prepare. Maybe that's why my formula and you suggested formula are not working correctly because the structure of my table?

eliabreupr_1-1657620242802.png

 

eliabreupr_0-1657620160471.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.