Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe'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
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
I have a measure called "Don’t feel overstressed" which gives my KPI value dynamically.
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
The KPI value changes over time, so I want these thresholds and colors to adjust dynamically based on the current KPI value.
Solved! Go to Solution.
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.
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. 🙂
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)
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
You should see something like this. I've given the KPI an arbitrary value of 5
Regards
Phil
Proud to be a Super User!
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.
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)
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
You should see something like this. I've given the KPI an arbitrary value of 5
Regards
Phil
Proud to be a Super User!
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.
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. 🙂
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 40 | |
| 35 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 71 | |
| 70 | |
| 38 | |
| 35 | |
| 23 |