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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
RAYAN123
New Member

Conditional formatting for matrix column headers based on closed month

Hi all,

I am working with a Power BI matrix where I have months (January–December) displayed as column headers, as shown in the screenshot. no value will display, only the column

Kindly ask for below request solution

  • Dynamically change the background color of the column headers
  • If a month is financially closed → show green
  • If a month is still open → show grey

I have a DAX in my model (e.g., a measure or flag indicating whether a month is closed):

Closed Month Flag =
IF(
    SELECTEDVALUE('Time'[IsClosedMonth]) = TRUE(),
    1,
    0
)

so the challenge is only related to applying the formatting to the headers.

Thanks for support!
Screenshot 2026-06-18 095130.png

2 REPLIES 2
Rupa01
Responsive Resident
Responsive Resident

Hi @RAYAN123

Currently, Power BI does not support conditional formatting for matrix column headers. Conditional formatting can only be applied to values within the visual, not to row or column headers.

If your requirement is to dynamically color the month header itself, you can use the Deneb custom visual.
 
I have provided below Deneb custom visual example using Sample Data - Time Sample
Rupa01_0-1781862514381.png

1. Create a custom column MonthHeaderColor

MonthHeaderColor = 
IF(
    'Time Sample'[IsClosedMonth] = TRUE(),
    "#70AD47",   -- Green
    "#A6A6A6"    -- Grey
)

2. Add Month, MonthNo, IsClosedMonth and MonthHeaderColor to the Values in Deneb Visual.

3. Edit Visual and select Vega-Lite (empty).

4. Add below to the Specification section and Run.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": { "name": "dataset" },

  "transform": [
    {
      "calculate": "'Header'",
      "as": "HeaderRow"
    }
  ],

  "width": { "step": 70 },
  "height": 45,

  "layer": [
    {
      "mark": {
        "type": "rect",
        "stroke": "white",
        "strokeWidth": 1,
        "cornerRadius": 2
      },
      "encoding": {
        "x": {
          "field": "Month",
          "type": "ordinal",
          "sort": { "field": "MonthNo", "order": "ascending" },
          "axis": null
        },
        "y": {
          "field": "HeaderRow",
          "type": "nominal",
          "axis": null
        },
        "color": {
          "field": "MonthHeaderColor",
          "type": "nominal",
          "scale": null,
          "legend": null
        },
        "tooltip": [
          { "field": "Month", "type": "nominal", "title": "Month" },
          { "field": "IsClosedMonth", "type": "nominal", "title": "Closed?" }
        ]
      }
    },
    {
      "mark": {
        "type": "text",
        "align": "center",
        "baseline": "middle",
        "fontSize": 13,
        "fontWeight": "bold",
        "color": "white"
      },
      "encoding": {
        "x": {
          "field": "Month",
          "type": "ordinal",
          "sort": { "field": "MonthNo", "order": "ascending" }
        },
        "y": {
          "field": "HeaderRow",
          "type": "nominal"
        },
        "text": {
          "field": "Month",
          "type": "nominal"
        }
      }
    }
  ],

  "config": {
    "view": {
      "stroke": null
    }
  }
}

5. Result 

Rupa01_1-1781863094984.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer
Rupa01
Responsive Resident
Responsive Resident

@RAYAN123did you get a chance to review the solution provided?

If it helped resolve your issue, please consider marking it as Accepted Solution so it can benefit others in the community as well.

Let me know if you need any further assistance! 👍

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors