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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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

1 REPLY 1
Rupa01
Frequent Visitor

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

 

💡 Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!

 Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.

 

Best Regards,

BI & Fabric Analytics Engineer. @Rupa01  

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

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