Forum Discussion
Conditional formatting of measures
Hi Trescher
Unfortunately, Power BI doesn't have built-in dynamic formatting that automatically applies to multiple measures at once. Each measure needs individual conditional formatting rules. However, we can create a maintainable system using a single formatting measure that all the measures reference.
Create a single formatting measure that determines color based on any input value:
Universal Color Format =
VAR CurrentValue = SELECTEDMEASURE() // Gets the value of whichever measure is being formatted
RETURN
IF(
ISBLANK(CurrentValue),
"#FFFFFF", // White for blank
IF(
CurrentValue >= 0,
"#00B050", // Green for >= 0
"#FF0000" // Red for < 0
)
)
Apply this to each measure individually
Select your table/matrix visual
Go to Format pane → Field formatting
Find Measure A → Conditional formatting → Font color
Choose "Field value" and select the [Universal Color Format] measure
Repeat for Measure B, Measure C, etc.
Thanks Krishnakanth, i tried this but somehow my matrix only results into white values which indicates that this formula results in blank/null values.
See screenshots below. The icons work perfectly as expected but the coloring font does not.
Do you have any idea why?
Thx
- krishnakanth2408 months ago
Super User
Hi Trescher
Thanks for confirming!
For the color change to black, Go to 'Format Visual' after selecting the visual
Navigate to 'Specific column'
Choose 'measure' from Series (In Apply settings to)
Navigate to 'Values'
Change the 'Text color'
Please give headsup it is working fine and accept it as a solution to help other community members. Thank You!
- Trescher8 months agoFrequent Visitor
Hi,
Whats the point of this if i need to change the text back to black again? The icons work, but the function you provided does not.
The problem is that the function doesnt evaluate per cell with SELECTEDMEASURE() to return a value for the coloring.