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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
QAA91
Regular Visitor

Conditional formatting

PlannedActual
100%100%
50%50%
60%80%
40%20%
blankblank

Hi, how to apply background colour based on conditions above.

1. Both Planned and Actual equal to 100% - format the cell to BLUE

2. Both Planned and Actual are equal to each other but less than 100% - format the cell to GREEN

3. Actual greater than Planned - format the cell to GREEN

4. Actual less than Planned - format the cell to RED

5. Both Planned and Actual blank - format the cell to GRAY

3 ACCEPTED SOLUTIONS
AilleryO
Memorable Member
Memorable Member

Hi,

 

You can create a measure like this :

 

Colors of Tasks = SWITCH( TRUE(),
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )=1 , "#0000CD", //blue
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )<1 , "#98FB98", //green
SELECTEDVALUE( TaskList[Actual] ) > SELECTEDVALUE( TaskList[Planned] ) , "#7FFF00", //green other
SELECTEDVALUE( TaskList[Actual] ) < SELECTEDVALUE( TaskList[Planned] ) , "#FF0000", //red
ISBLANK( SELECTEDVALUE( TaskList[Actual] ) ) && ISBLANK( SELECTEDVALUE( TaskList[Planned] ) ) , "#D3D3D3", //grey
"#FFFFFF" //else white
)
 
and then use it in Conditionnal formatting using (values of fields) :
 
MEFC_values.png
Hope it make sense for you otherwise do not hesitate to ask for more details.
 
Have a nice day

View solution in original post

amitchandak
Super User
Super User

@QAA91 , You can create a measure like

Assuming they are % column

 

color

Switch( True() ,

[Planned] =1 && [Actual] =1, "Blue" ,

([Planned] =[Actutal] && [Actual] <> 1) || [Planned] < [Actutal] , "Green" ,

[Planned] > [Actutal] , "Red",

"Grey"

)

 

Use this in conditional formating using the field value option.

 

A blank value will not take any color

PowerBI Abstract Thesis: How to do conditional formatting by measure and apply it on pie? : https://youtu.be/RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

AilleryO
Memorable Member
Memorable Member

Hi, Sorry one mistake in my formula, you should do the test for blank at first otherwise when both are blanks you'll get green because both have same value ;-=

So the formula should be :

 

Colors of Tasks = SWITCH( TRUE(),
ISBLANK( SELECTEDVALUE( TaskList[Actual] ) ) && ISBLANK( SELECTEDVALUE( TaskList[Planned] ) ) , "#D3D3D3", //grey
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )=1 , "#0000CD", //blue
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )<1 , "#98FB98", //green
SELECTEDVALUE( TaskList[Actual] ) > SELECTEDVALUE( TaskList[Planned] ) , "#7FFF00", //green other
SELECTEDVALUE( TaskList[Actual] ) < SELECTEDVALUE( TaskList[Planned] ) , "#FF0000", //red
"#FFFFFF" //else white
)
 
Do not forget to check as solved if this works as expected

View solution in original post

6 REPLIES 6
ao292
New Member

Still on my journey in Power BI but check out my answer below:

 

Indicator = SWITCH(
TRUE(),
Data[Planned] = 1 && Data[Actual] = 1, 0,
Data[Planned] = Data[Actual] && Data[Planned] < 1 && Data[Actual] < 1, 1,
Data[Actual] > Data[Planned], 2,
Data[Actual] < Data[Planned], 3,
ISBLANK(Data[Actual]) && ISBLANK(Data[Planned]), 4
)
 
After set up the conditional formatting as below:
 
ConditionalFormatting - Background.PNG
AilleryO
Memorable Member
Memorable Member

Hi, Sorry one mistake in my formula, you should do the test for blank at first otherwise when both are blanks you'll get green because both have same value ;-=

So the formula should be :

 

Colors of Tasks = SWITCH( TRUE(),
ISBLANK( SELECTEDVALUE( TaskList[Actual] ) ) && ISBLANK( SELECTEDVALUE( TaskList[Planned] ) ) , "#D3D3D3", //grey
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )=1 , "#0000CD", //blue
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )<1 , "#98FB98", //green
SELECTEDVALUE( TaskList[Actual] ) > SELECTEDVALUE( TaskList[Planned] ) , "#7FFF00", //green other
SELECTEDVALUE( TaskList[Actual] ) < SELECTEDVALUE( TaskList[Planned] ) , "#FF0000", //red
"#FFFFFF" //else white
)
 
Do not forget to check as solved if this works as expected
amitchandak
Super User
Super User

@QAA91 , You can create a measure like

Assuming they are % column

 

color

Switch( True() ,

[Planned] =1 && [Actual] =1, "Blue" ,

([Planned] =[Actutal] && [Actual] <> 1) || [Planned] < [Actutal] , "Green" ,

[Planned] > [Actutal] , "Red",

"Grey"

)

 

Use this in conditional formating using the field value option.

 

A blank value will not take any color

PowerBI Abstract Thesis: How to do conditional formatting by measure and apply it on pie? : https://youtu.be/RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much

AilleryO
Memorable Member
Memorable Member

Hi,

 

You can create a measure like this :

 

Colors of Tasks = SWITCH( TRUE(),
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )=1 , "#0000CD", //blue
SELECTEDVALUE( TaskList[Actual] ) = SELECTEDVALUE( TaskList[Planned] ) && SELECTEDVALUE( TaskList[Actual] )<1 , "#98FB98", //green
SELECTEDVALUE( TaskList[Actual] ) > SELECTEDVALUE( TaskList[Planned] ) , "#7FFF00", //green other
SELECTEDVALUE( TaskList[Actual] ) < SELECTEDVALUE( TaskList[Planned] ) , "#FF0000", //red
ISBLANK( SELECTEDVALUE( TaskList[Actual] ) ) && ISBLANK( SELECTEDVALUE( TaskList[Planned] ) ) , "#D3D3D3", //grey
"#FFFFFF" //else white
)
 
and then use it in Conditionnal formatting using (values of fields) :
 
MEFC_values.png
Hope it make sense for you otherwise do not hesitate to ask for more details.
 
Have a nice day

Thank you very much

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.