Forum Discussion
Conditional Formatting in Power BI Matrix Based on Dynamic KRI Status Thresholds
Anonymous , First, you need to create a measure that will determine the color based on the thresholds for each KRI. This measure will use the thresholds from the KRI table to evaluate the results in the KRI results table.
DAX
KRI Color =
VAR KRI_ID = SELECTEDVALUE('KRI results'[Id])
VAR Result = SELECTEDVALUE('KRI results'[Result])
VAR RedMin = LOOKUPVALUE('KRI'[Grenswaarde Rood Min], 'KRI'[ID], KRI_ID)
VAR RedMax = LOOKUPVALUE('KRI'[Grenswaarde Rood Max], 'KRI'[ID], KRI_ID)
VAR OrangeMin = LOOKUPVALUE('KRI'[Grenswaarde Oranje Min], 'KRI'[ID], KRI_ID)
VAR OrangeMax = LOOKUPVALUE('KRI'[Grenswaarde Oranje Max], 'KRI'[ID], KRI_ID)
VAR YellowMin = LOOKUPVALUE('KRI'[Grenswaarde Geel Min], 'KRI'[ID], KRI_ID)
VAR YellowMax = LOOKUPVALUE('KRI'[Grenswaarde Geel Max], 'KRI'[ID], KRI_ID)
VAR GreenMin = LOOKUPVALUE('KRI'[Grenswaarde Groen Min], 'KRI'[ID], KRI_ID)
VAR GreenMax = LOOKUPVALUE('KRI'[Grenswaarde Groen Max], 'KRI'[ID], KRI_ID)
RETURN
SWITCH(
TRUE(),
Result < RedMin || Result > RedMax, "Red",
(Result >= OrangeMin && Result <= OrangeMax), "Orange",
(Result >= YellowMin && Result <= YellowMax), "Yellow",
(Result >= GreenMin && Result <= GreenMax), "Green",
"No Color"
)
Once you have the measure, you can apply it to the matrix visual for conditional formatting.
Select the matrix visual.
Go to the "Format" pane.
Expand the "Conditional formatting" section.
Choose the field you want to format (e.g., "Title").
Click on "Background color" or "Font color".
In the conditional formatting dialog, choose "Field value" and select the measure you created (e.g., KRI Color).
Adjust the Measure for Your Specific Thresholds: Ensure that the measure correctly references the threshold columns in your KRI table. If your thresholds are stored differently (e.g., as ranges in a single column), you may need to adjust the measure accordingly.
- Anonymous1 year agoNot applicable
Hi bhanu,
Thanks for getting back to me and it would be a great solution, however, some of my boundaries are two sided. What I mean by this is that e.g. KPI1 has the boundaries for red of either <6 or >20. So your solution doesn't work here, otherwise it would be great!