Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

SUM multiple month values (January) over years

I'm trying to sum multiple month values over several years e.g. Jan 2007, Jan 2008, Jan 2009.

 

I'm using the following formula however when I try push the date forward 12 months it comes back to the orignial value e.g. (Jan 2007) + Jan 2007 instead of (Jan 2007 + Jan 2008)

 

Is there a way to achieve multiple Jan additions?

 

PBIX

https://www.dropbox.com/s/giyeda55w6ybv7f/Monthly%20Average%20Over%20Years.pbix?dl=0

Niiru1_0-1634027536007.png

Niiru1_1-1634027565282.png

I am using Alberto Ferrari's "Rolling Average" file as a sample template

 

My DAX is

Aggregation 2 =
CALCULATE (

SUMX (
Sales,
Sales[Quantity] * Sales[Net Price]
),
ALLEXCEPT (
'Date',
'Date'[Month]
),DATESINPERIOD('Date'[Date],FIRSTDATE('Date'[Date]),1,MONTH))

+


CALCULATE (
SUMX (
Sales,
Sales[Quantity] * Sales[Net Price]
),
ALLEXCEPT (
'Date',
'Date'[Month]
),DATESINPERIOD('Date'[Date],FIRSTDATE('Date'[Date]),1,MONTH),EDATE('Date'[Date],12))
1 ACCEPTED SOLUTION

Hi, @Anonymous 

I think there is no need to use DATESMTD.

76.png

 

NY_Sales Amount = CALCULATE(Sales[Sales Amount],DATEADD('Date'[Date],-1,YEAR) )
Year after NY_Sales Amount = CALCULATE(Sales[Sales Amount],DATEADD('Date'[Date],-2,YEAR) )
_Aggregation = [Sales Amount]+[NY_Sales Amount]+[Year after NY_Sales Amount] 

 

Please check the attachment for more details. If it doesn't meet your requirement, please feel free to ask.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Based on what I got, try measure one like below with help from date table

 

last three year same month  Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
+ CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))

+ CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-24,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Thanks for this,I'm getting this result when I enter the measure, I've tried filtering out the -12 and -24 month and it still gives me the same result

 

I'm using 'Date' [Calendar Year] and 'Date'[Month] as my rows do you think this is the issue as the measure you've suggested is calling 'Date'[Date]

 

Niiru1_0-1634031015560.png

 

Hi, @Anonymous 

I think there is no need to use DATESMTD.

76.png

 

NY_Sales Amount = CALCULATE(Sales[Sales Amount],DATEADD('Date'[Date],-1,YEAR) )
Year after NY_Sales Amount = CALCULATE(Sales[Sales Amount],DATEADD('Date'[Date],-2,YEAR) )
_Aggregation = [Sales Amount]+[NY_Sales Amount]+[Year after NY_Sales Amount] 

 

Please check the attachment for more details. If it doesn't meet your requirement, please feel free to ask.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.