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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Mohan_Vanku
Frequent Visitor

dynamic conditional formatting

Hi everyone

I am trying to apply conditional formatting in a Matrix visual in Power BI based on a KPI measure.

Here is what I want to achieve

  1. I have a measure called "Don’t feel overstressed" which gives my KPI value dynamically.

  2. I want to apply conditional formatting to the Matrix such that

    • From 0 to the half of KPI value  → Red color (low performance)

    • Half from KPI value to the KPI value → Green color (approaching target)

    • Above the KPI value → White color

  3. The KPI value changes over time, so I want these thresholds and colors to adjust dynamically based on the current KPI value.

2 ACCEPTED SOLUTIONS
ThomasWeppler
Impactful Individual
Impactful Individual

Add a DAX code
Don’t feel overstressed color =
IF (
    [meassure] >= 0 && [meassure] < DIVIDE ( [Don't feel overstressed], 2 ),
    1,
    IF (
        [meassure] >= DIVIDE ( [Don't feel overstressed], 2 )
            && [meassure] < [Don't feel overstressed],
        2,
        3
    )
)

Then

Choose the KPI in your matrix and press the arrow down. then go to conditional formatting and pick bagground color.

 

 

ThomasWeppler_2-1762437879549.png

 

 

Pick the format style rules and add 2 new rules then pick the color you want when [Don’t feel overstressed color] has the value 1, 2 and 3

I hope this help. 🙂

 

 

 

View solution in original post

PhilipTreacy
Super User
Super User

Hi @Mohan_Vanku 

 

Download example PBIX with the code and data shown below

 

You can create a measure that generates the hex color code based on your rules about the values in relation to the Don't feel overstressed measure :

 

Matrix CF = 

SWITCH( TRUE(),

[Sale inc Tax] > [Don't feel overstressed], "#FFF", //WHITE

[Sale inc Tax] > [Don't feel overstressed] / 2, "#0F0", //GREEN

"#F00" //RED
)

 

Then you select Conditional Formatting -> Backgroudn color from the drop down menu for the matrix values (note that I'm obviously using my own dummy data here)

 

PhilipTreacy_0-1762822433242.png

 

In the CF settings, choose Format style -> Field value and then choose the measure just created Matrix CF as the field to decide the colors, click OK

 

PhilipTreacy_1-1762822500820.png

 

You should see something like this.  I've given the KPI an arbitrary value of 5

 

PhilipTreacy_2-1762822589654.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
v-priyankata
Community Support
Community Support

Hi @Mohan_Vanku 

Thank you for reaching out to the Microsoft Fabric Forum Community.

@PhilipTreacy @ThomasWeppler Thanks for the inputs.

I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

Hi @Mohan_Vanku 

Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.

PhilipTreacy
Super User
Super User

Hi @Mohan_Vanku 

 

Download example PBIX with the code and data shown below

 

You can create a measure that generates the hex color code based on your rules about the values in relation to the Don't feel overstressed measure :

 

Matrix CF = 

SWITCH( TRUE(),

[Sale inc Tax] > [Don't feel overstressed], "#FFF", //WHITE

[Sale inc Tax] > [Don't feel overstressed] / 2, "#0F0", //GREEN

"#F00" //RED
)

 

Then you select Conditional Formatting -> Backgroudn color from the drop down menu for the matrix values (note that I'm obviously using my own dummy data here)

 

PhilipTreacy_0-1762822433242.png

 

In the CF settings, choose Format style -> Field value and then choose the measure just created Matrix CF as the field to decide the colors, click OK

 

PhilipTreacy_1-1762822500820.png

 

You should see something like this.  I've given the KPI an arbitrary value of 5

 

PhilipTreacy_2-1762822589654.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


ThomasWeppler
Impactful Individual
Impactful Individual

Add a DAX code
Don’t feel overstressed color =
IF (
    [meassure] >= 0 && [meassure] < DIVIDE ( [Don't feel overstressed], 2 ),
    1,
    IF (
        [meassure] >= DIVIDE ( [Don't feel overstressed], 2 )
            && [meassure] < [Don't feel overstressed],
        2,
        3
    )
)

Then

Choose the KPI in your matrix and press the arrow down. then go to conditional formatting and pick bagground color.

 

 

ThomasWeppler_2-1762437879549.png

 

 

Pick the format style rules and add 2 new rules then pick the color you want when [Don’t feel overstressed color] has the value 1, 2 and 3

I hope this help. 🙂

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.