Forum

Notifications
Clear all

Conditional Formatting - PowerBI DAX

4 Posts
2 Users
0 Reactions
92 Views
(@glenisat)
Posts: 6
Active Member
Topic starter
 

Hello,

I am currently trying to apply some conditional formatting on my powerbi dashboard. However, it doesn't seem like it's accepting negative percentage when I go through the 'conditional formatting' option. So what I have done so far is I wrote a DAX formula which consists of 'if' statements. 

So what I would like to happen is:

anything is at 0 variance or higher = green
within 5% of goal = yellow
below 5% of goal = red

So I wrote a Dax - then reference this DAX formula to apply a conditional formatting.
CF =
IF(
[Variance 1(%)] < -0.05, 1,
IF(
[Variance 1(%)] <-.04, 2,
IF(
[Variance 1(%)] >= 0,
3)))
 
Specifically for the second formula - I need numbers mark as yellow if it's between certain numbers. So basically between -0.5% and 0. I keep getting errors Cry
 
Posted : 15/09/2022 3:35 pm
Philip Treacy
(@philipt)
Posts: 1631
Member Admin
 

Hi Glenisa,

If you supplied your file that would help to see your measure and data, but without it I can only give an example of this formatting.

The DAX to create the colours for the CF can be this

 

Variance 1(%) =

VAR _val = MAX('DataTable'[Value])

RETURN

SWITCH ( TRUE(),

_val >= 0 , "Green",

_val >= -0.05 , "Yellow",

"Red"

)
 
Which gives this
 
power bi conditional formatting
 
Check my attached file to see the data and code I've used.
 
Regards
 
Phil
 
 
Posted : 15/09/2022 11:07 pm
(@glenisat)
Posts: 6
Active Member
Topic starter
 

Is there a way for me to do apply a conditional formatting if a value falls into a certain range. 

For example:

If value >= -5% percent and < 0% then it YELLOW

 
Posted : 23/09/2022 4:23 pm
Philip Treacy
(@philipt)
Posts: 1631
Member Admin
 

Yes, my code already does that.  Have you tried using it?

regards

Phil

 
Posted : 23/09/2022 10:20 pm
Share: