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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
antoinepal
Frequent Visitor

Rolling 12 months Sum for each month in a table visual

Hello,

 

I have a table visual with date, date year-1 and sum of sales. I would like to have an extra column-measure to show sum of sales fro the previous 12 months for each date in the table. Below is a screenshot of how the table visual looks like.

 

antoinepal_0-1599063093050.png

I tried several measures but seems impossible.

 

Can you help?

1 ACCEPTED SOLUTION

Hi @antoinepal ,

 

If you need a measure , you can just use the measure below:

 

 

Measure =
VAR _pyear = MAX('Table'[Date-1Y])
VAR _current = MAX('Table'[Date])
RETURN
CALCULATE( SUM ('Table'[Sales]), ALL ( 'Table'), 'Table'[Date] <= _current && 'Table'[Date] >= _pyear)

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@antoinepal , try with a date calendar

example

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))
Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-12,MONTH))
Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,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 :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
fhill
Resident Rockstar
Resident Rockstar

 

Try this as a Calcualted Column...  

 

SUM_DateDiff =
VAR _pyear = 'Table'[Date-1Y]
RETURN
CALCULATE( SUM ('Table'[Sales]), FILTER( ALL ( 'Table'), 'Table'[Date] <= EARLIER('Table'[Date]) && 'Table'[Date] >= _pyear))

 

fhill_0-1599064169997.png

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Thank you for your response.

For each date i would like  to have the sales for 12 months period.

 

For example, for 1/5/2018 i would like to have sales from 1/5/2017 to 1/5/2018

For 1/4/2018 i would like to have sales from 1/4/2017 to 1/4/2018 etc. This for each date in the visual.

 

I believe a measure needed as this is a table visual. The data in the query have different structure.

 

Thanks once again!

 

Hi @antoinepal ,

 

If you need a measure , you can just use the measure below:

 

 

Measure =
VAR _pyear = MAX('Table'[Date-1Y])
VAR _current = MAX('Table'[Date])
RETURN
CALCULATE( SUM ('Table'[Sales]), ALL ( 'Table'), 'Table'[Date] <= _current && 'Table'[Date] >= _pyear)

 

 

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

 

Best Regards,

Dedmon Dai

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.