cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Highlight max and min values in a visual

Hi,

 

I tried to use conditional formatting to display the min and max values of a measure in a matrix; I did not find how to do so.

I followed this topic but it does not allow to highlight both min and max.

 

In my case, I have 4 regions and a measure containing the sales. I want to display the cells in green where sales are max for a region and in red where sales are min for a region.

 

Could you explain me how to do this?

Thanks

 

EDIT: the topic I linked allows to highlight min and max (if you create var 'min' and var 'max'). But is this method the only way to have this result?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User IV
Super User IV

Re: Highlight max and min values in a visual

Hello @Anonymous 

You can use a measure like this to feed the color to the conditional formatting.  

FormatMeasure = 
VAR MaxAmount = CALCULATE(MAXX(VALUES('Table'[Region]),[Sales Amount]),ALL('Table'[Region]))
VAR MinAmount = CALCULATE(MINX(VALUES('Table'[Region]),[Sales Amount]),ALL('Table'[Region]))
VAR LineAmonut = [Sales Amount]
RETURN 
SWITCH (
    TRUE(),
    LineAmonut = MaxAmount, "GREEN",
    LineAmonut = MinAmount, "RED"
    )    

In my example I format [Sales Amount] based on the Field value of the [FormatMeasure]:

conditionalformatminmax.jpg

This will format only the hightest and lowest out of all the regions meaning, if you welect Central, Southeast and Southwest none of them would be formatted because none of those are the highest or lowest.

If you want it to highlight the hightest and lowest out of all the visable regions it would look like so.

FormatMeasure = 
VAR SelectedRegions = ALLSELECTED('Table'[Region])
VAR MaxAmount = CALCULATE(MAXX(SelectedRegions,[Sales Amount]),SelectedRegions)
VAR MinAmount = CALCULATE(MINX(SelectedRegions,[Sales Amount]),SelectedRegions)
VAR LineAmonut = [Sales Amount]
RETURN 
SWITCH (
    TRUE(),
    LineAmonut = MaxAmount, "GREEN",
    LineAmonut = MinAmount, "RED"
    )

View solution in original post

1 REPLY 1
Super User IV
Super User IV

Re: Highlight max and min values in a visual

Hello @Anonymous 

You can use a measure like this to feed the color to the conditional formatting.  

FormatMeasure = 
VAR MaxAmount = CALCULATE(MAXX(VALUES('Table'[Region]),[Sales Amount]),ALL('Table'[Region]))
VAR MinAmount = CALCULATE(MINX(VALUES('Table'[Region]),[Sales Amount]),ALL('Table'[Region]))
VAR LineAmonut = [Sales Amount]
RETURN 
SWITCH (
    TRUE(),
    LineAmonut = MaxAmount, "GREEN",
    LineAmonut = MinAmount, "RED"
    )    

In my example I format [Sales Amount] based on the Field value of the [FormatMeasure]:

conditionalformatminmax.jpg

This will format only the hightest and lowest out of all the regions meaning, if you welect Central, Southeast and Southwest none of them would be formatted because none of those are the highest or lowest.

If you want it to highlight the hightest and lowest out of all the visable regions it would look like so.

FormatMeasure = 
VAR SelectedRegions = ALLSELECTED('Table'[Region])
VAR MaxAmount = CALCULATE(MAXX(SelectedRegions,[Sales Amount]),SelectedRegions)
VAR MinAmount = CALCULATE(MINX(SelectedRegions,[Sales Amount]),SelectedRegions)
VAR LineAmonut = [Sales Amount]
RETURN 
SWITCH (
    TRUE(),
    LineAmonut = MaxAmount, "GREEN",
    LineAmonut = MinAmount, "RED"
    )

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors