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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
KL008
Helper I
Helper I

Conditional Formatting in Power BI Matrix Based on Dynamic KRI Status Thresholds

Hi everyone,

I'm working on a Power BI report and need some help with conditional formatting in a matrix visual. I have two tables: KRI and KRI results, connected by a one-to-many relationship between KRI[ID] and KRI results[Id].

In the KRI table, there are four columns of interest: "Grenswaarde Rood", "Grenswaarde Oranje", "Grenswaarde Geel", and "Grenswaarde Groen". These columns specify the status thresholds for each KRI. For example, for KRI with Id = 9, the thresholds are:

  • Red: <6% or >20%
  • Orange: 6-8% or 18-20%
  • Yellow: 8-10% or 16-18%
  • Green: 10-16%

But the thresholds for another KRI will be different since they are measuring different results and information.

 

I want to display the KRIs from the KRI results table in a matrix where:

  • Rows: KRI name
  • Columns: Organization level
  • Values: Title (which contains the results)

I need the background color of the cells to change based on the status thresholds specified in the KRI table. However, each KRI has different thresholds, so the formatting needs to be dynamic.

 

Does anybody have any tips and tricks for this?

7 REPLIES 7
Anonymous
Not applicable

Hi @KL008, hello Poojara_D12  and bhanu_gautam, thank you for your prompt reply!

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

 

Do not include sensitive information or anything not related to the issue or question.

KRI Results:

IDKRI IDResultDepartmentQuarter
1708Marketing1
2704Sales1
37019IT1
4715Marketing1
5718Sales1
6713IT1
7706Marketing2
8707Sales2
9707.5IT2
10714Marketing2
11715.5Sales2
12717IT2

 

KRI Info:

IDKRI IDKRI NameRedOrangeYellow Green
170% retained<6 or >206-8 or 18-208-10 or 16-1810-16
271% absent>= 76-74.5-6<4.5


In my matrix I use KRI results table. In the rows I have KRI ID, in the columns I have department and in the Values I have result. Is it possible to implement conditional formatting here?

Anonymous
Not applicable

Hi @KL008 , thank you for your sample data.

 

Based on my tests and research, there doesn't appear to be an out-of-the-box solution for this requirement.

 

The challenge lies in the need to dynamically obtain and apply different formatting rules for various colors within a single measure. Each color has its own unique formatting rule, which adds to the complexity.

 

Best regards,

Joyce

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Poojara_D12
Super User
Super User

Hi @KL008 

To dynamically format the matrix cells based on KRI thresholds:

  1. Create a DAX Measure: Write a measure to calculate the status (Red, Orange, Yellow, Green) based on the KRI table thresholds:

 

Status = 
VAR Value = MAX('KRI results'[Result])
VAR RedLow = LOOKUPVALUE('KRI'[Red Low], 'KRI'[ID], MAX('KRI results'[Id]))
VAR RedHigh = LOOKUPVALUE('KRI'[Red High], 'KRI'[ID], MAX('KRI results'[Id]))
-- Add similar variables for Orange, Yellow, Green
RETURN
    SWITCH(
        TRUE(),
        Value < RedLow || Value > RedHigh, "Red",
        -- Add conditions for Orange, Yellow, Green
        "Green"
    )

 

 

  • Add to Matrix: Use the Status measure in the matrix as the Values field.
  • Apply Conditional Formatting:
    • Format the Title column in the matrix with conditional formatting.
    • Use the Field value option and select the Status measure.
    • This will color cells dynamically based on KRI-specific thresholds.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Hi Poojara, again thanks for you insight but it doesn't work here for me. The boundary for red can be either <6 or >20.

bhanu_gautam
Super User
Super User

@KL008 , 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.

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






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!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.