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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dawaro
Frequent Visitor

Need Help With Conditional Formatting Table Data

I have a simple table visual that I need to apply conditional formatting to a measure and I have been searching all day and trying Copilot and have gotten no where.

This is an example of the table visual.

PriorityActual HoursPercentage of Hours
P115

10.7%

P285.7%
P311783.6%
Total140100.0%

 

My data cloumns are 'KPI'[Actual Hours], 'KPI'[Priority] with a measure to calculate the Percentage of Hours.

Percentage of Hours =
DIVIDE(
    SUM('Sheet1'[# of Actual Hours]),
    CALCULATE(SUM('Sheet1'[# of Actual Hours]), ALL('Sheet1'[Priority])),
    0
)
 
What I need to do is change the color of the text to Red if the P1 percentage is >5%, P2 percentage is >15% and P3 percentage is <80%.
I have tried several different measures and calculated columns but nothing seems to work.
 
Can someone point out what I am missing?
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@dawaro add a new measure for color and then use this in the conditional formatting using field value:

 

Color = 
VAR __SelectedPriority - SELECTEDVALUE ( 'KPI'[Priority] )
VAR __SelectedPercent = [Percentage of Hours]
VAR __KPIColor = "Red" //of add hex code
RETURN
//I'm using switch for better readability and easy maintenance, you can always IF
SWITCH (
   TRUE (),
   __SelectedPriority = "P1" && __SelectedPercent > 0.05, __KPIColor,
   __SelectedPriority = "P2" && __SelectedPercent > 0.15, __KPIColor, 
   __SelectedPriority = "P3" && __SelectedPercent < 0.80, __KPIColor
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
pankajnamekar25
Super User
Super User

Hello  Dawaro,

 

I tried you can check the attched screenshot.

pankajnamekar25_0-1742903245709.png

 

I created a measure based on the condition based on condictinal formatting Background color based on rules  and selected color measure if it is =1 then red else default color 

 

Thanks,
Pankaj

If this solution helps, please accept it and give a kudos, it would be greatly appreciated.

 

Anonymous
Not applicable

Hi @dawaro ,
Thank you @parry2k  and @Deku for the prompt response!

As @parry2k suggested ,the query help you to get the expected output.I tried this solution, and it works great!
Please refer the screenshot :

vpagayammsft_0-1742897284062.png

Hope this helps,If so  please mark it as "Accept as solution" .
If you need any further assistance, feel free to reach out.

Thank you for being a valued member of the Microsoft Fabric Community Forum!

Regards,
Pallavi.

 
parry2k
Super User
Super User

@dawaro add a new measure for color and then use this in the conditional formatting using field value:

 

Color = 
VAR __SelectedPriority - SELECTEDVALUE ( 'KPI'[Priority] )
VAR __SelectedPercent = [Percentage of Hours]
VAR __KPIColor = "Red" //of add hex code
RETURN
//I'm using switch for better readability and easy maintenance, you can always IF
SWITCH (
   TRUE (),
   __SelectedPriority = "P1" && __SelectedPercent > 0.05, __KPIColor,
   __SelectedPriority = "P2" && __SelectedPercent > 0.15, __KPIColor, 
   __SelectedPriority = "P3" && __SelectedPercent < 0.80, __KPIColor
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Deku
Super User
Super User

var Priority = SELECTEDVALUE( 'KPI'[Priority] )
return
IF(
   ( Priority  = "P1" && [Percentage of Hours] > 0.05) || 
   ( Priority  = "P2" && [Percentage of Hours] > 0.15) || 
   ( Priority  = "P3" && [Percentage of Hours] < 0.8), 
   "#FF0000"
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.