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
Binway
Helper II
Helper II

Date filter that crosses over years

Hi

Our Year starts on the 01/04 and I need to sum sales for the YTD eg currrently from April to August.

The calculation I am using is below that has a dynamic end Date.

YTD Amount = CALCULATE(SUM(Sales[Amount])
,DATESBETWEEN('Date'[Date],DATE(YEAR(TODAY()),4,1), EOMONTH(TODAY(),0))

 

I have created a calculation that works fine for now but as the Calendar Year moves to Next year it will fail.

I have done some investigation but couldn't easily find anything to suit - the DATESYTD function didn't seem appropriate.

 

Appreciate the help.

 

Binway

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

YTD Amount = CALCULATE(SUM(Sales[Amount]),DATESYTD('Date'[Date],"31/3"))

 

Ensure that there is a relationshiop from the Date column of the Sales Table to the Date column of the Date Table.  In the Date Table, use this calculated column formulas to extract the Year and month

 

Year=YEAR('Date'[Date])

Month=FORMAT('Date'[Date],"mmmm")

 

Create 2 slicers - one each for Year and Month.  Select any one year and month in the slicers.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

YTD Amount = CALCULATE(SUM(Sales[Amount]),DATESYTD('Date'[Date],"31/3"))

 

Ensure that there is a relationshiop from the Date column of the Sales Table to the Date column of the Date Table.  In the Date Table, use this calculated column formulas to extract the Year and month

 

Year=YEAR('Date'[Date])

Month=FORMAT('Date'[Date],"mmmm")

 

Create 2 slicers - one each for Year and Month.  Select any one year and month in the slicers.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Excellent thanks.

I thought the DATESYTD function would sum everything up til 31/3 next year but it seems it only sums up until TODAY().

Looks good.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.