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
tom-lenzmeier
Helper I
Helper I

Dynamic Column Header In a Matrix

Hello,

I have a matrix that has 6 value measures: Last 12 months sales/change, last 6 month sales/sales change, and last 3 month sales/change. I have been tasked with trying to figure out if I can add a slicer where the user selects either 12, 6, or 3 months. Ideally, we would have two values being used (sales & sales change) depending on the slicer value selected. Is there a way to have the column header change depending on the value selected? For example, if they chose the last 12 months, the matrix would show the sales for the last 12 months and the YoY change in sales. The header would say "L12M Sales" and "L12M Sales Chg.". Then if 6 is chosen the values naturally change but I'm hoping that the header changes too. 

I can get it to work for a single value, but then I get stuck.

1 ACCEPTED SOLUTION
cengizhanarslan
Solution Sage
Solution Sage

You can do it cleanly with a Field parameter. Here’s a concrete example you can copy.

First, create your measures (you already have these, names just for example):

  • [L12M Sales], [L12M Sales Chg]

  • [L6M Sales], [L6M Sales Chg]

  • [L3M Sales], [L3M Sales Chg]

1) Create the field parameter table

Modeling → New parameter → Fields (pick the 6 measures). Power BI will generate something like:

KPI Param =
{
    ("L12M Sales",      NAMEOF([L12M Sales]),      0),
    ("L12M Sales Chg",  NAMEOF([L12M Sales Chg]),  1),
    ("L6M Sales",       NAMEOF([L6M Sales]),       2),
    ("L6M Sales Chg",   NAMEOF([L6M Sales Chg]),   3),
    ("L3M Sales",       NAMEOF([L3M Sales]),       4),
    ("L3M Sales Chg",   NAMEOF([L3M Sales Chg]),   5)
}

 

Those text labels (“L12M Sales”, etc.) become your dynamic column headers.

2) Create a slicer for 12 / 6 / 3

Period Selector =
DATATABLE("Months", INTEGER, {{12},{6},{3}})

Put Period Selector[Months] on a slicer.

3) Filter the field parameter based on the slicer

Add this calculated column to the KPI Param table:

KPI Param[PeriodMonths] =
SWITCH(
    TRUE(),
    CONTAINSSTRING(KPI Param[Name], "L12M"), 12,
    CONTAINSSTRING(KPI Param[Name], "L6M"),  6,
    CONTAINSSTRING(KPI Param[Name], "L3M"),  3
)

Now create a relationship:

  • Period Selector[Months] → KPI Param[PeriodMonths] (one-to-many)

4) Build the matrix

  • Rows: whatever dimensions you need (Product, Customer, etc.)

  • Columns: KPI Param (the field parameter)

  • Values: KPI Param (Power BI handles this automatically when you drop the parameter)

Now when the user selects 12, they only see:

  • L12M Sales

  • L12M Sales Chg

…and the headers change automatically because the parameter labels are different.

That’s the simplest way to get two measures shown + dynamic headers driven by a 12/6/3 slicer.

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn

View solution in original post

8 REPLIES 8
cengizhanarslan
Solution Sage
Solution Sage

You can do it cleanly with a Field parameter. Here’s a concrete example you can copy.

First, create your measures (you already have these, names just for example):

  • [L12M Sales], [L12M Sales Chg]

  • [L6M Sales], [L6M Sales Chg]

  • [L3M Sales], [L3M Sales Chg]

1) Create the field parameter table

Modeling → New parameter → Fields (pick the 6 measures). Power BI will generate something like:

KPI Param =
{
    ("L12M Sales",      NAMEOF([L12M Sales]),      0),
    ("L12M Sales Chg",  NAMEOF([L12M Sales Chg]),  1),
    ("L6M Sales",       NAMEOF([L6M Sales]),       2),
    ("L6M Sales Chg",   NAMEOF([L6M Sales Chg]),   3),
    ("L3M Sales",       NAMEOF([L3M Sales]),       4),
    ("L3M Sales Chg",   NAMEOF([L3M Sales Chg]),   5)
}

 

Those text labels (“L12M Sales”, etc.) become your dynamic column headers.

2) Create a slicer for 12 / 6 / 3

Period Selector =
DATATABLE("Months", INTEGER, {{12},{6},{3}})

Put Period Selector[Months] on a slicer.

3) Filter the field parameter based on the slicer

Add this calculated column to the KPI Param table:

KPI Param[PeriodMonths] =
SWITCH(
    TRUE(),
    CONTAINSSTRING(KPI Param[Name], "L12M"), 12,
    CONTAINSSTRING(KPI Param[Name], "L6M"),  6,
    CONTAINSSTRING(KPI Param[Name], "L3M"),  3
)

Now create a relationship:

  • Period Selector[Months] → KPI Param[PeriodMonths] (one-to-many)

4) Build the matrix

  • Rows: whatever dimensions you need (Product, Customer, etc.)

  • Columns: KPI Param (the field parameter)

  • Values: KPI Param (Power BI handles this automatically when you drop the parameter)

Now when the user selects 12, they only see:

  • L12M Sales

  • L12M Sales Chg

…and the headers change automatically because the parameter labels are different.

That’s the simplest way to get two measures shown + dynamic headers driven by a 12/6/3 slicer.

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn

I have 3 other line charts on the page with the matrix. Is it possible to get them to switch too? 

I found the answer to my own question. Thanks for your assistance.

Quick question. Would it be beneficial to use my calendar table for the integers? I could filter the slicer to only include 12, 6, and 3.

I would prefer keeping it in a different table as you are going to use in for parameters. Keeping them in your calander table could break measures depending on your measures.

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
danextian
Super User
Super User

Hi @tom-lenzmeier 

 

Have you tried using field parameters and an extra column to the parameter table to be used in the slicer?

 

danextian_0-1766550135147.png

Current Year, Revenue, Transactions and Variance are the extra column in the parameter table above. In your case, you can use 12, 6, 3. The Parameter column values are what will appear in your visual.

danextian_1-1766550271598.gif

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Headers cannot be dynamic.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
tom-lenzmeier
Helper I
Helper I

One more thing, I know I can do it with bookmarks, but it would be cool if I could avoid that.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.