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

I want to display the previous year value for the time range that has been selected in the timeline

Hi

 

I want to show previous year value for total sales for the time range that has been selected in the slicer.

slicer.JPG

 

Suppose in this slicer I have selected a date range of 02-02-2016 to 04-05-2016 so the total value of sales to be displayed should be

of previous year i.e, 02-02-2015 to 04-05-2015.

3 REPLIES 3

There is a dax function SAMEPERIODLASTYEAR that will do this https://msdn.microsoft.com/en-us/library/ee634972.aspx



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

@MattAllingtonMy data is transactional data. In slicer it has invoice date and the function that you suggested gives the formula like

CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(DateTime[DateKey]))

Can you please tell me what is  (DateTime[DateKey]) is it a different table for calendar.? As in this scenario I want us invoice date in place of DateTime[DateKey] As my report is depenedent on invoice date. Can you sugggest me a way to do this.

 

This is my DAX -:

Previous Year Measure = CALCULATE(SUM('table1'[Total]), SAMEPERIODLASTYEAR('table1'[Invoice Date].[Date]))

This does not show the correct data.

Power BI has layers of functionality.  If you just want to add columns of data then you can just use a single table.  If you want to perform time intelligence calculations, you need a calendar table.  Here are a couple of my articles that will help.

 

https://exceleratorbi.com.au/power-pivot-calendar-tables/

https://exceleratorbi.com.au/dax-time-intelligence-beginners/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.