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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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