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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dynamic Column Name change Based on Slicer Selection

I have a measure named current year(2021-2022) and Prev Year (2020-2021).

 

My requirement is to change the column name based on the slicer selection, here the slicer is year column.

 

Example : When i select 2020-2021 and 2021-2022 in the display Year slicer, my current year column should change as "2021-2022" and prev year column should be "2020-2021"

 

Can anyone help me how to write DAX to change the column name dynamically ?

 

output is as below

vs_7_0-1645507440075.png

 

display year is slicer selection

vs_7_1-1645507463614.png

 

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Anonymous

You can use matrix visual to get that effect. The process is probably: create two measures, one is used to return the dynamic column header, and the other measure is placed in the value field of matrix. FYI: Dynamic column header in MatrixMessage 3.

 

 

Best Regards,

Community Support Team _Tang

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

amitchandak
Super User
Super User

@Anonymous , Please check if this blog from Parry can help

Show dynamic column name
https://perytus.com/2021/02/04/improve-ux-show-year-in-legend-when-using-time-intelligence-measures/

 

Or you need a hybrid table workaround. Display two years using an independent table and then create a hybrid table

 

if you are looking for a Hybrid display with Matrix Column and measure
https://community.powerbi.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-PowerBI/ba-p/1354591
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-New-Hotness-Custom-Matrix-Hierarchy/m-p/963588#M428

vote for Hybrid Table
https://ideas.powerbi.com/ideas/idea/?ideaid=9bc32b23-1eb1-4e74-8b34-349887b37ebc

 

Show 2 year when 1 is selected - then use Hybrid Table

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

can i set column name in dax base on slicer selection.

below is my dax.

current Year =
CALCULATE(sum(Sales[F Net Value_CR]),FILTER(Master_Calendar,Master_Calendar[F Year]=year(TODAY()-365) ))
 
Pre Year = CALCULATE(sum(Sales[F Net Value_CR]),FILTER(Master_Calendar,Master_Calendar[F Year]=year(TODAY()-730)))
 
if i select 2020-2021 , column name should be change current Year to  (2021-2022) and pre year change to 2020-2021.
 
output is showing as below
 
vs_7_0-1645511523642.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors