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

can we set column name in dax which is change in slicer selection

hi i have calculated  dax , where i want change column name in dax.

 

example: in slicer i select 2021-2022, column name should be change  current Year to  "2021-2022"

and if i select 2020-2021 and 2021-2022 , column name should be change  current Year to  "2021-2022" and Pre Year to 2020-2021

 

 

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)))
 
below is output
vs_7_0-1645509826758.png

 

slicer is below.

 

vs_7_1-1645509879593.png

 

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Since there are serveral tables and many data, please share me with your pbix file after removing sensitive data to solve your issue more quickly.

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

Best Regards,
Eyelyn Qin

 

amitchandak
Super User
Super User

@Anonymous , refer 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/

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

hey thanku😀, now your dax is working but i am facing one problem..value is showing same , total and BH & state wise wise value is showing same. please help

Sales New =
//get selected year, if no year is selected or more than one year is selected
//then get the most recent year from the table
VAR __selectedYear =
SELECTEDVALUE (
'Master_Calendar'[F Year],
YEAR ( TODAY() )
)
//get previous year by simply substracting one from the selected year
VAR __prevYear = __selectedYear - 1
RETURN
CALCULATE (
Sales[AAA],
//turn off the relationship between the date and fact table
CROSSFILTER ( 'Master_Calendar'[Date_N], Sales[CDate], NONE ),
KEEPFILTERS (
TREATAS (
{ __selectedYear, __prevYear },
//apply filter to the fact table on the selected and prev year
Sales[Year]
)
)
)

 

vs_7_0-1645519445422.png

 

Anonymous
Not applicable

when i used you dax ,below error is showing.

 

vs_7_0-1645512437807.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