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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
kaweckil
New Member

Get column headers to dynamically fit to frame

Hi,

 

I wanted to see if the column headers in a matrix could be set to fit to a frame dynamically? The number of column headers depends on a slicer. I want the column headers to fill the frame of the matrix at all times.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @kaweckil 

Based on your description, I've created the following sample data:

vjianpengmsft_0-1724116983514.png

I've created the following measures:

Actuals1 = SUM(SalesData[Actuals])
Budgets1 = SUM(SalesData[Budgets])
Forecasts1 = SUM(SalesData[Forecasts])
Var_Act_vs_Fcst = [Actuals1] - [Forecasts1]
Var_Act_vs_Bud = [Actuals1] - [Budgets1]

vjianpengmsft_1-1724117157269.png

To be able to dynamically change the matrix header based on the slicer selection, I created the following header table:

vjianpengmsft_2-1724117294951.png

I use the following DAX expression to create a measure that toggles the measure for the corresponding matrix header:

MatrixValues = 
SWITCH(
    MAX(Mappings[TableHeaders]),
    "Actual", [Actuals1],
    "Budget", [Budgets1],
    "Forecast", [Forecasts1],
    "Var Act vs Fcst", [Var_Act_vs_Fcst],
    "Var Act vs Bud", [Var_Act_vs_Bud]
)

I've created a matrix with these fields, and a slicer with the TableHeaders field:

vjianpengmsft_3-1724117445266.png

When I select the corresponding title in the slicer, the title of the matrix also changes automatically:

vjianpengmsft_4-1724117539997.png

vjianpengmsft_5-1724117553429.png

I have provided the PBIX file used this time below for your reference. In addition, you can learn about the current method of dynamically switching matrix headers through the following link:

Solved: Dynamically changing matrix column headers based o... - Microsoft Fabric Community

Solved: Dynamic Column Names for Matrix Visual using Slice... - Microsoft Fabric Community

Dynamic Column Headers in Power BI Customize with Inforiver

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi, @kaweckil 

Based on your description, I've created the following sample data:

vjianpengmsft_0-1724116983514.png

I've created the following measures:

Actuals1 = SUM(SalesData[Actuals])
Budgets1 = SUM(SalesData[Budgets])
Forecasts1 = SUM(SalesData[Forecasts])
Var_Act_vs_Fcst = [Actuals1] - [Forecasts1]
Var_Act_vs_Bud = [Actuals1] - [Budgets1]

vjianpengmsft_1-1724117157269.png

To be able to dynamically change the matrix header based on the slicer selection, I created the following header table:

vjianpengmsft_2-1724117294951.png

I use the following DAX expression to create a measure that toggles the measure for the corresponding matrix header:

MatrixValues = 
SWITCH(
    MAX(Mappings[TableHeaders]),
    "Actual", [Actuals1],
    "Budget", [Budgets1],
    "Forecast", [Forecasts1],
    "Var Act vs Fcst", [Var_Act_vs_Fcst],
    "Var Act vs Bud", [Var_Act_vs_Bud]
)

I've created a matrix with these fields, and a slicer with the TableHeaders field:

vjianpengmsft_3-1724117445266.png

When I select the corresponding title in the slicer, the title of the matrix also changes automatically:

vjianpengmsft_4-1724117539997.png

vjianpengmsft_5-1724117553429.png

I have provided the PBIX file used this time below for your reference. In addition, you can learn about the current method of dynamically switching matrix headers through the following link:

Solved: Dynamically changing matrix column headers based o... - Microsoft Fabric Community

Solved: Dynamic Column Names for Matrix Visual using Slice... - Microsoft Fabric Community

Dynamic Column Headers in Power BI Customize with Inforiver

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.