Forum Discussion
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
display year is slicer selection
3 Replies
- amitchandak
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#M428vote for Hybrid Table
https://ideas.powerbi.com/ideas/idea/?ideaid=9bc32b23-1eb1-4e74-8b34-349887b37ebcShow 2 year when 1 is selected - then use Hybrid Table
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
- AnonymousNot 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
- v-xiaotang
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 Matrix, Message 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.