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

Get Fabric certified for FREE! Don't miss your chance! Learn more

EsraaKamal

Streamlining Conditional Formatting in Power BI: DAX Workarounds & The Case for Global Rules

Conditional formatting is one of the most powerful tools in Power BI for highlighting insights and trends. A pop of red or green instantly tells the story behind the numbers.

But every Power BI developer knows the pain: applying formatting visual by visual, and column by column, is incredibly repetitive, especially on complex financial dashboards.

In this blog, I will share practical DAX strategies you can use today to centralize your formatting logic, saving you hours of clicking. Then, I’ll open a discussion on a feature I believe we desperately need: Measure-Level Conditional Formatting Rules.

Part 1: The Current Challenge (The "12-Month Matrix" Problem)
To understand why this is painful, consider a standard Financial P&L Matrix. You have metrics like Total Profit displayed across 12 columns (January through December).

Looking at a plain table of numbers makes it hard to spot trends quickly.

Currently, to highlight negative values in red, you must manually open the formatting pane for January, set the rule, then repeat the exact same process for February, March, and so on. If you change your mind later (e.g., you want negative values to be Orange instead of Red), you have to edit it 12 separate times. This leads to maintenance nightmares and inconsistent reporting.

Metrix.PNG 

Part 2: The "Survival" Strategy (Centralized DAX Logic)
Until we get native page-level controls, the best strategy is to centralize your formatting logic using DAX.

Instead of using the standard "Rules" interface within the formatting pane (which locks logic into a single visual or column), we will use the "Field Value" option.

Step 1: Create a "Color Logic" Measure
First, create a dedicated measure that defines your color logic in one place. Using the SWITCH(TRUE()...) pattern allows you to define complex rules and return specific Hex codes.

Here is a measure designed for a general financial metric:

Formatting_Color = 
SWITCH( TRUE(),
    -- Red for negative values (Loss)
    SUM(Financials[Amount]) < 0, "#FF0000", 
    
    -- Yellow for low positive values (Between 0 and 5k)
    SUM(Financials[Amount]) >= 0 && SUM(Financials[Amount]) < 5000, "#FFFF00", 
    
    -- Teal/Dark Green for high values (Above 5k)
    SUM(Financials[Amount]) >= 5000, "#057576", 
    
    -- Default white background for any other case
    "#FFFFFF" 
)

 

Step 2: Apply as "Field Value"
This is the magic step. Instead of defining rules, we tell Power BI to use the color codes generated by our measure.

  1. Select your Matrix visual.
  2. Go to the Format pane -> Cell elements.
  3. Turn Background color On and click the fx icon.
  4. In the dialog box, change Format style to Field value and select your measure.

EsraaKamal_1-1769525256359.png

The Result
Instantly, your entire matrix, across all 12 months, is formatted based on that single measure. If you ever need to change a color, you update the DAX measure once, and everything updates automatically.
Metrix with formatting.PNG

 

Part 3: Leveling Up (Row & Column Specific Logic)
What if you don't want to color everything? The standard formatting tools apply rules to the "Values" generally, but DAX allows us to be surgical. We can target specific rows or specific columns.

Scenario A: Targeting a Specific Row (Row-Level) Let's say you only want to highlight the "Profit" row but leave the "Sales" row clean. We can modify our measure to check the context of the current row [Category].

Formatting_Profit_Row_Only = 
VAR CurrentCategory = SELECTEDVALUE(Financials[Category])
VAR CurrentAmount = SUM(Financials[Amount])

RETURN
SWITCH( TRUE(),
    -- Rule 1: If the row is 'Profit' and value is negative, apply RED
    CurrentCategory = "Profit" && CurrentAmount < 0, "#FF0000", 
    
    -- Rule 2: If the row is 'Profit' and value is positive, apply GREEN
    CurrentCategory = "Profit" && CurrentAmount >= 0, "#00FF00",
    
    -- Default: Leave other rows (e.g., Sales) unformatted/white
    BLANK() 
)

When you apply this measure using the same "Field Value" technique, you get a much cleaner, more professional result where only the key information is highlighted.
Formatting row.PNGMetrix with formatting row.PNG

Scenario B: Targeting a Specific Column (Column-Level) Conversely, maybe you want to highlight a specific time period—for example, making the December column stand out in Gold to draw attention to year-end performance.

Formatting_Dec_Column_Only = 
VAR CurrentMonth = SELECTEDVALUE(Financials[Month])

RETURN
IF( 
    -- Check if the current column is December
    CurrentMonth = "Dec", 
    "#FFD700", -- Apply Gold color
    BLANK()    -- Keep other months unformatted
)

By switching the "Field Value" to this new measure, you instantly highlight just that vertical column across all your metrics.

Formatting column.PNGMetrix with formatting Column.PNG

 

Part 4: The Dream Feature (True Page-Level Rules)
While the DAX method above is a powerful workaround, it still requires us to manually apply the "Field Value" setting to every single visual.
This brings me to my proposal for the Power BI team.
The Concept: Page-Level Conditional Formatting
Imagine if the Page Canvas itself had a conditional formatting menu. You wouldn't need to touch individual charts or matrices.
Instead, you would go to the Page Settings and define a global rule:

                             "For this Page: Anywhere [Total Profit] is used, apply this Red/Green logic."
How it would work:

  1. Define Once: You set the rule in the Page Format pane.
  2. Cascade Automatically: Power BI automatically pushes this formatting to every visual on that page—whether it is a Card, a Bar Chart, or a Matrix.
  3. Row-Level Option: Ideally, this feature would also include a toggle to "Apply to Row Background", solving the matrix problem instantly without needing complex DAX measures.

The Connection:
This contrasts with the DAX method because it centralizes the application. You wouldn't need to open the "Cell Elements" menu for 10 different visuals. You set it at the Page level, and you are done.

 

Conclusion & Call to Action
Using DAX "Field Value" measures is currently our best defense against repetitive formatting work. It keeps your logic centralized and allows for advanced scenarios like row-level highlighting.
However, I believe native Page-Level Conditional Formatting (with options for row-level cascading) would be a game-changer for report developers.
Vote for the Idea, I have submitted this as a feature request in the Ideas forum. If you agree that this would make our lives easier, please vote here: Page-Level Conditional Formatting Rules in Power BI

What do you think? Do you use the DAX method, or do you have another trick for managing formatting at scale? Let's discuss in the comments below

Comments