Forum Discussion
To select previous year data from time slicer
Hi Friends,
I have an year slicer in my report which is like this.
and a date slicer in my report which looks something like this. the below slicer is dependent on the above year slicer.
So I want to create 2 cards the one card shows the data for the time selected in the slicer and the other shows the data for the previous year of that slicer.
For E.g.-: If in my slicer the date selected is from 19-02-2016 to 25-04-2016 so one of the card should display the data of the time slected and the other card should display the data for the previous year of the same time like it should display the data for 19-02-2015 to 25-04-2015
so whatever the the selection is done in the slicer the (Current Year) card will show the data of that very time period and (Last Year) card will show the data of previous year for the same date and month but date will change.
Seems like that would be SAMEPERIODLASTYEAR function:
https://msdn.microsoft.com/en-us/library/ee634972.aspx
4 Replies
- Greg_DecklerCommunity Champion
Seems like that would be SAMEPERIODLASTYEAR function:
https://msdn.microsoft.com/en-us/library/ee634972.aspx
- afaque03Helper I
Greg_DecklerI want to display the previous year value for the time range that has been selected in the timeline slicer. Can you suggest me DAX for it
- Eric_ZhangMicrosoft Employee
afaque03 wrote:
Greg_DecklerI want to display the previous year value for the time range that has been selected in the timeline slicer. Can you suggest me DAX for it
Supposing there's a calendar table in your case, if the currentYear measure is as
currentYear = SUM(yourTable[value])
Then a measure for previous year shall work
previousYear = CALCULATE([currentYear],SAMEPERIODLASTYEAR('calendar'[Date]))However my concern is about the interaction between those slicers, per my test, the dates slicer in your case won't reflect according to the Year slicer.