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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
afaque03
Helper I
Helper I

To select previous year data from time slicer

Hi Friends,

 

I have an year slicer in my report which is like this.

yearslicer.JPG

 

and a date slicer in my report which looks something like this. the below slicer is dependent on the above year slicer.

 

slicer.JPG

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

 

year card.JPG

 

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.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Seems like that would be SAMEPERIODLASTYEAR function:

 

https://msdn.microsoft.com/en-us/library/ee634972.aspx

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Seems like that would be SAMEPERIODLASTYEAR function:

 

https://msdn.microsoft.com/en-us/library/ee634972.aspx

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@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


@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


@afaque03

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. 

@Eric_ZhangSAMEPERIODLASTYEAR function worked for me but the issue is if i put any other filter in that report and select that filter the card does not populate any data. The card does not display.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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