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
APM
Helper I
Helper I

Sum sales between a set date and today (TY and LY)

Hello,
 
I'm trying to calculate sales for the season TY and LY. The season starts on December 1st of the prior year.
 
I'm using these formulas:
2021 Season Sales $ =
CALCULATE(
    SUM(STD_RETAIL_SALES_REPORT[Selling_Price]),
    DATESBETWEEN('Date'[Date].[Date],12/1/2020,DATE(YEAR(NOW())-1,MONTH(NOW()), DAY(NOW()-1))
))
 
2022 Season Sales $ =
CALCULATE(
    SUM(STD_RETAIL_SALES_REPORT[Selling_Price]),
    DATESBETWEEN('Date'[Date].[Date],12/01/2021,TODAY()))
 
The results are wildly incorrect.
 
What am I doing wrong?
 
My data:
 
APM_0-1648571437619.png

 

And I have a simple date table and a relationship between that date table and the 'Action_Date' field.

 

 APM_1-1648571514808.png

 

APM_2-1648571571288.png

Thanks for your help!

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @APM 

You can try using these two functions to help you.

EOMONTH

EDATE

 

example:

https://community.powerbi.com/t5/Desktop/Add-Results-of-a-different-Measure-for-last-12-months/m-p/2...

 

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@APM , if there is not filter used

this year =

CALCULATE(
SUM(STD_RETAIL_SALES_REPORT[Selling_Price]),filter('Date', year('Date'[Date]) = Year(Today())))

 

last year =

CALCULATE(
SUM(STD_RETAIL_SALES_REPORT[Selling_Price]),filter('Date', year('Date'[Date]) = Year(Today()) -1 ))

 

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Hey,

 

But where in the formula might I specify that the period start is 12/1/2020 and 12/01/2021?

 

I tried to adapt your formula to this with no luck:

 

2021 STD $ =
CALCULATE(
SUM(STD_RETAIL_SALES_REPORT[Selling_Price]),filter('Date','Date'[Date] >= 12/1/2020),FILTER('Date',DATE(YEAR(NOW())-1,MONTH(NOW()), DAY(NOW()-1))))

In essence,

 

I just want to be able to obtain sales from

 

12/1/2020 to 'today' last year (and for today that would be 3/28/2021)

 

and

 

12/1/2021 to 'today' (3/28/2022).

 

In excel this would be absurdly simple, in DAX it's turning out to be quite the conundrum.

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.