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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Rolling Total for Past 12 Months

I have a date table and Financial table.

 

If I select a particular monthyear from slicer of date table then my visual should display rolling total of previous 12 months sales sum from that selected monthyear.

 

Eg if I select july 2014, then my visual should display Rolling sum of sales from july 2013 to july 2014. i.e sales of February will be sum of Jan and feb, Sales of March should be sum of Jan,Feb and March and so on.

 

My code - 

rolling total =
var currentdate = MAX('Date'[Date])
var period = DATESINPERIOD('Date'[Date],currentdate,-12,MONTH)
return

CALCULATE(SUM(financials[ Sales]),FILTER(ALL('Date'[Date]),'Date'[Date]<=currentdate),period)
 
But I am getting wrong output:
Capture.PNG
 

 

How do I do that?

1 REPLY 1
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this measure:

rolling total 12 =
VAR _Date =
    MAX ( 'Date'[Date] )
VAR _LDate =
    DATE ( YEAR ( _Date ) - 1, MONTH ( _Date ), DAY ( _Date ) )
RETURN
    CALCULATE (
        SUM ( financials[Sales] ),
        FILTER ( ALL ( 'Date' ), 'Date'[Date] <= _Date && 'Date'[Date] > _LDate )
    )

 

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

Appreciate your Kudos!!

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.