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
Huskyjimbo
Frequent Visitor

Calc YTD for time period one month prior to current date

I want to calculate total units sold  YTD of a specific type of product for a period starting in Jan and ending in the month previous to current month. I need a similar calc for previous years also.

 

For example:

Total units of Diamondback55250 sold for period between Jan2018-Sept2018 (since current month is Oct)

Total units of Diamondback55250 sold for period between Jan2017-Sept2017 (since current month is Oct)

Total units of Diamondback55250 sold for period between Jan2016-Sept2016 (since current month is Oct)

 

and when the current month changes to November it should show:

Total units of Diamondback55250 sold for period between Jan2018-Oct2018 (since month would be Nov)

Total units of Diamondback55250 sold for period between Jan2017-Oct2017 (since month would be Nov)

Total units of Diamondback55250 sold for period between Jan2016-Oct2016 (since month would be Nov)

 

So far I have:

 

Total Units of Diamondback55250 sold = calculate(sumx('Sales', 'Sales'[Units]), filter('Sales', 'Sales'[Product_Code]= "55250"))

 

This gives me the totals but it doesn't:

A.) cut off the total a month before current month

and

B.) Give me the total units sold for the same time period of previous years.


Any help would be gretly appreciated. 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

Measure1=calculate(sum('Sales'[Units]),'Sales'[Product_Code]="55250",DATESBETWEEN(Calendar[Date],DATE(YEAR(TODAY()),1,1),EOMONTH(TODAY(),-1)))

 

Measure2=calculate(sum('Sales'[Units]),'Sales'[Product_Code]="55250",DATESBETWEEN(Calendar[Date],DATE(YEAR(TODAY())-1,1,1),EOMONTH(EDATE(TODAY(),-12),-1)))

 

Hope this helps.


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

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @Huskyjimbo

You may try to use TOTALYTD Function and TODAY Function to add a measure as below:

Measure = CALCULATE(TOTALYTD([Total Units of Diamondback55250 sold],'Calendar'[Date]),FILTER('Calendar',MONTH('Calendar'[Date])<MONTH(TODAY())))

Result:

1.PNG

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

Measure1=calculate(sum('Sales'[Units]),'Sales'[Product_Code]="55250",DATESBETWEEN(Calendar[Date],DATE(YEAR(TODAY()),1,1),EOMONTH(TODAY(),-1)))

 

Measure2=calculate(sum('Sales'[Units]),'Sales'[Product_Code]="55250",DATESBETWEEN(Calendar[Date],DATE(YEAR(TODAY())-1,1,1),EOMONTH(EDATE(TODAY(),-12),-1)))

 

Hope this helps.


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.