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

Error 12 Month Rolling SUM

Hey there!
I'm trying to calculate the sum of Sales 12 month rolling back. I found a formula, but it is not working well, it has an error, it's not including Feb-2019 sales.

 

Rolling 12 meses Sales = CALCULATE([Sales];FILTER(ALL(TC[Fecha]);AND(TC[Fecha]<=MAX(Resultados[Fecha]);DATEADD(TC[Fecha];1;YEAR)>MAX(Resultados[Fecha]))))
 

recorte.JPG

Dif=15360177-14796582=563594 : February Sales

Any suggestion?
Thanks!

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @mmazzalay 

I have seen odd behavior if you use time intelligence functions (DATEADD) without a calendar table that goes from Jan 1st - Dec 31st for all the years in your model.

See if this measure gives any different results

Rolling 12 meses Sales =
CALCULATE ( [Sales]; DATESINPERIOD ( TC[Fecha]; MAX ( TC[Fecha] ); -1; YEAR ) )

And if not, try adding a calendar table and linking it to your data table and using the dates there which would look something like this.

Rolling 12 meses Sales = CALCULATE([Sales];DATESINPERIOD(calendario[Fecha];MAX(calendario[Fecha]);-1,YEAR))

 

If this solves your issues please mark it as the solution so that others can find it easily. Kudos 👍 are nice too.
John

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

Hello @mmazzalay 

I have seen odd behavior if you use time intelligence functions (DATEADD) without a calendar table that goes from Jan 1st - Dec 31st for all the years in your model.

See if this measure gives any different results

Rolling 12 meses Sales =
CALCULATE ( [Sales]; DATESINPERIOD ( TC[Fecha]; MAX ( TC[Fecha] ); -1; YEAR ) )

And if not, try adding a calendar table and linking it to your data table and using the dates there which would look something like this.

Rolling 12 meses Sales = CALCULATE([Sales];DATESINPERIOD(calendario[Fecha];MAX(calendario[Fecha]);-1,YEAR))

 

If this solves your issues please mark it as the solution so that others can find it easily. Kudos 👍 are nice too.
John

I tried with the first option and it works perfectly!!!😁

Thanks! It was very helpfull!

 

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.