cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Measure for LY Sales for Range of Dates

HI there,

 

I have a measure to calculate the sales for a range of dates taken from a slicer:

 

Sales for Date Range = CALCULATE(SUM(Sales[NetTotal]), FILTER(Sales, AND(Sales[CheckDate].[Date] <= MAX('Calendar'[Date]), Sales[CheckDate].[Date] >= MIN('Calendar'[Date])) ))

 

What I am trying to figure out is how to create a measure for the same period LY.  My work has the need to pull reports for all different kinds of date ranges and compare them to the same period last year, so my "Today", "MTD", "YTD", "LY  MTD", "LY YTD" measures are not quite cutting it, and I'm having difficulty with phrasing the MIN/MAX dates to go back a year.

 

Any suggestions most appreciated!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Measure for LY Sales for Range of Dates

Hi @golfgirl1111,

 

You can try to use below formula to achieve your requirement if it suitable for your requirement:

MTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[MonthNo]),VALUES('Calendar'[Date].[Year]))

YTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[Year]))

LY MTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESMTD(Calendar[Date]),-1,YEAR))

LY YTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESYTD(Calendar[Date]),-1,YEAR))

 

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Super User I
Super User I

Re: Measure for LY Sales for Range of Dates

Hi @golfgirl1111

 

Can you please some sample data and the output you expect.  If you have the pbix and share it on one-drive with the link , it will help find the right solution.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Highlighted
Community Support
Community Support

Re: Measure for LY Sales for Range of Dates

Hi @golfgirl1111,

 

You can try to use below formula to achieve your requirement if it suitable for your requirement:

MTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[MonthNo]),VALUES('Calendar'[Date].[Year]))

YTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[Year]))

LY MTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESMTD(Calendar[Date]),-1,YEAR))

LY YTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESYTD(Calendar[Date]),-1,YEAR))

 

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors