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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Rolling sum of sales for three years

Hi,

 

I would like to calculate a rolling sum of sales for three years, the current and two previuos ones. An example is below:

venice23_0-1675195118856.png

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Anonymous 

try like:
NewCalculatedColumn =
VAR _year = [Year]
RETURN
SUMX(
    FILTER(
        TableName,
        TableName[Year] IN {_year, _year-1, _year-2}
    ),
    TableName[Sales]
)
 
FreemanZ_0-1675218119433.png

 

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

hi @Anonymous 

try like:
NewCalculatedColumn =
VAR _year = [Year]
RETURN
SUMX(
    FILTER(
        TableName,
        TableName[Year] IN {_year, _year-1, _year-2}
    ),
    TableName[Sales]
)
 
FreemanZ_0-1675218119433.png

 

Anonymous
Not applicable

Hi @FreemanZ ,

I am just trying to finilise my query. How would the measure look like if one more colomn, i.e. 'colour', had to be introduced?

 

venice23_0-1675354238845.png

 

Anonymous
Not applicable

This solution works well for me, thank you!

hi @Anonymous 

or you can plot a table visual with the Year column and a measure like:
Measure =
VAR _year = MAX(TableName[Year])
RETURN
SUMX(
    FILTER(
        ALL(TableName),
        TableName[Year] IN {_year, _year-1, _year-2}
    ),
    TableName[Sales]
)
FreemanZ_1-1675218204011.png

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.