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
cn4422
Helper V
Helper V

Switch Measure - conditional formatting

Hi,

 

I have several switch-measures in a matrix table, like this example here:

 

 Switch = SWITCH(SELECTEDVALUE(Countries[Country]),
"AT",DIVIDE([G AT],[L AT],0),
"BE",DIVIDE([G BE],[L BE],0),
"CH",DIVIDE([G CH],[L CH],0),
    )
 
Is it possible to apply conditional formatting with a three-color gradient to each row individually, so that each row (only values, no sum) is evaluated in its own context rather than across all rows?
 
Many thx in advance!
 
2025-02-19 11_46_18-CPL Länderübersicht 2025 08 Country Split by table - Import.png
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@cn4422 , 

Create a Measure for Conditional Formatting: You need to create a measure that will be used for the conditional formatting. This measure should return a value that can be used to determine the color gradient.


ConditionalFormattingMeasure =
SWITCH(
TRUE(),
SELECTEDVALUE(Countries[Country]) = "AT", DIVIDE([G AT], [L AT], 0),
SELECTEDVALUE(Countries[Country]) = "BE", DIVIDE([G BE], [L BE], 0),
SELECTEDVALUE(Countries[Country]) = "CH", DIVIDE([G CH], [L CH], 0)
)


Apply Conditional Formatting: Once you have the measure, you can apply conditional formatting to the matrix table.

Go to the matrix visual in your Power BI report.
Click on the dropdown arrow next to the measure you want to format.
Select "Conditional formatting" and then "Background color" or "Font color" depending on your preference.
In the conditional formatting dialog, choose "Field value" and select the ConditionalFormattingMeasure you created.
Set the color scale to a three-color gradient and configure the minimum, midpoint, and maximum values as needed.




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

Proud to be a Super User!




LinkedIn






View solution in original post

3 REPLIES 3
bhanu_gautam
Super User
Super User

@cn4422 , 

Create a Measure for Conditional Formatting: You need to create a measure that will be used for the conditional formatting. This measure should return a value that can be used to determine the color gradient.


ConditionalFormattingMeasure =
SWITCH(
TRUE(),
SELECTEDVALUE(Countries[Country]) = "AT", DIVIDE([G AT], [L AT], 0),
SELECTEDVALUE(Countries[Country]) = "BE", DIVIDE([G BE], [L BE], 0),
SELECTEDVALUE(Countries[Country]) = "CH", DIVIDE([G CH], [L CH], 0)
)


Apply Conditional Formatting: Once you have the measure, you can apply conditional formatting to the matrix table.

Go to the matrix visual in your Power BI report.
Click on the dropdown arrow next to the measure you want to format.
Select "Conditional formatting" and then "Background color" or "Font color" depending on your preference.
In the conditional formatting dialog, choose "Field value" and select the ConditionalFormattingMeasure you created.
Set the color scale to a three-color gradient and configure the minimum, midpoint, and maximum values as needed.




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

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam,

thanks for your reply and the provided measure and explanation!

The conditional formatting itself works fine.

 

2025-02-20 13_15_13-CPL Länderübersicht 2025 08 Country Split by table - Import.png

 

However, it considers all rows from all countries, using the highest and lowest values across all countries as reference points.

What I would like instead is for each row to reference only itself. In this case, we have only two rows—so for AT, the lowest value would be €47.19, and the highest would be €55.58, regardless of the other rows.

Is there a way to apply conditional formatting in this way?

@cn4422 , Not sure but trying separate measure than and use it

 

reate Individual Measures for Each Country: Create separate measures for each country that calculate the ratio or value you want to use for conditional formatting.
G_AT_L_AT_Ratio = DIVIDE([G AT], [L AT], 0)
G_BE_L_BE_Ratio = DIVIDE([G BE], [L BE], 0)
G_CH_L_CH_Ratio = DIVIDE([G CH], [L CH], 0)
Apply Conditional Formatting: Apply conditional formatting to each measure separately in the matrix visual.

Go to the matrix visual in your Power BI report.
Click on the dropdown arrow next to the measure you want to format (e.g., G_AT_L_AT_Ratio).
Select "Conditional formatting" and then "Background color" or "Font color" depending on your preference.
In the conditional formatting dialog, choose "Field value" and select the corresponding measure (e.g., G_AT_L_AT_Ratio).
Set the color scale to a three-color gradient and configure the minimum, midpoint, and 




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

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.