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
Anonymous
Not applicable

Possible to use a measure in conditional formatting?

I have a clustered bar chart and I'd like to set a min and max value that formats the bars a different color. The min and max threshold is different depending on slicer values. I have a Measure that calculates the min/max but can't figure out how to say "less than min measure" and "greater than max" measure in the conditional formatting screen.

 

I'm guessing it's not possible but thought I'd ask. Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Conditional formatting has few limitations. On a few visual, it not supported with legends and second measure.

 

You can use color scale , rule or field value.

For "Field value" create a measure like

 

Color Measure =
var _min = CALCULATE([Min Measure],ALL(Table))
var _max = CALCULATE([Max Measure],ALL(Table))
return switch(TRUE(),
[Percent %] <_Min , "Red",
[Percent %] >_max , "Green", "Blue")

 

 

Refer for steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , Conditional formatting has few limitations. On a few visual, it not supported with legends and second measure.

 

You can use color scale , rule or field value.

For "Field value" create a measure like

 

Color Measure =
var _min = CALCULATE([Min Measure],ALL(Table))
var _max = CALCULATE([Max Measure],ALL(Table))
return switch(TRUE(),
[Percent %] <_Min , "Red",
[Percent %] >_max , "Green", "Blue")

 

 

Refer for steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Greg_Deckler
Super User
Super User

@Anonymous Yes, you can use measures in conditional formatting. I believe it is Rules based that you want. Or you can use Field value in Format By

Greg_Deckler_0-1599871700462.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler.  I need the rule to be in the "Enter a value" section.

@Anonymous Sorry, where is the "Enter a value" section? Can you post a screen shot and point to where you mean? You are really better off doing all the logic in your measure as kind of color flag that returns like 1, 2, 3 based on the conditions you set.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_DecklerIn the screenshot you posted. Under the Minimum and Maximum sections. The grey boxes where you enter the min and max values.

@Anonymous Nope, can't do that there. That's why I suggested doing the logic in your measure itself to essentially create a flag. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@amitchandakThose links got me pointed in the right direction. Thanks!

 

2020-09-11_18h46_37.png

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.