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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SK87
Helper III
Helper III

Dynamic column based on slicer selection

Hi Team,

 

I have Slicer for Month-Year (Column name as select month). and have created Matrix table for 12 Months where will see sum of searches of last 12months from latest month. Now I need to see dynamic column based on selection of slicer.

Incase in slicer I have selected "October 2021"; column name should appear as " 12M (Jan 21 - Oct 21) {bold part should be dynamic}

 

For 12Months my calculation is:

Current Year = CALCULATE(SUM('Brands Final'[Search]), PARALLELPERIOD('Brands Final'[Select Month],0,YEAR))
Previous Year =
VAR CurrentYear = PARALLELPERIOD('Brands Final'[Select Month],0,YEAR)
VAR PreviousY = SAMEPERIODLASTYEAR(CurrentYear)
RETURN
CALCULATE([Sum of Search],PreviousY)
12M = 
CALCULATE(DIVIDE([Current Year],[Previous Year])-1)
 
In Matrix table, In values I have added 12M KPI measure.

Please suggest best suitable way to get dynamic column.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SK87 ,

If you want your field name to be displayed dynamically based on the slicer options, I'm afraid it can't be achieved... Maybe you could consider creating a measure as below and putting it on the card visual to display the field name info...

measure =
VAR _selmonth =
    SELECTEDVALUE ( 'Brands Final'[Select Month] )
RETURN
    "12M (" & [the month for 10 months ago] & " - " & _selmonth & ")"

Best Regards

View solution in original post

4 REPLIES 4
SK87
Helper III
Helper III

Can anyone help me on this.

 

@SpartaBI @tamerj1 

amitchandak
Super User
Super User

@SK87 ,

If you choose one month and what show more than that data on axis, ou need independent date table in slicer

 

example measure

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -12) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

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

 
 
This year
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1*month(_max) ) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))
 
 
Last year
 
This year
new measure =
var _max1 = maxx(allselected(Date1),Date1[Date])
var _max = Date(Year(_max1)-1, Month(_max1), Day(_max1))
var _min = eomonth(_max, -1*month(_max) ) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

You can also use

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your response but I am looking for dynamic column name; calculation Part of 12Months already done at my end.

Need Name as "12M (Jan 21 - Oct 21) " on selection of slicer "October 2021

If I select July 2021 it should be "12M (Oct 20 - Jul 21)

Anonymous
Not applicable

Hi @SK87 ,

If you want your field name to be displayed dynamically based on the slicer options, I'm afraid it can't be achieved... Maybe you could consider creating a measure as below and putting it on the card visual to display the field name info...

measure =
VAR _selmonth =
    SELECTEDVALUE ( 'Brands Final'[Select Month] )
RETURN
    "12M (" & [the month for 10 months ago] & " - " & _selmonth & ")"

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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