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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Rolling sum of sales for three years by colour

Hi, 

 

I would like to find a rolling sum for three years for every colour provided.


venice23_0-1675354238845.png

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Anonymous 

try to plot a visual with year and colour columns, and a measure like:

 

3YColourSum = 
VAR _year = MAX(TableName[year])
RETURN
SUMX(
    FILTER(
        ALL(TableName),
        TableName[Colour] = MAX(TableName[Colour])
            &&TableName[Year] IN {_year, _year-1, _year-2}
    ), 
    TableName[Sales]
)

 

it worked like:

FreemanZ_0-1675662926487.png

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@FreemanZ 
Thank you! It worked well.

Anonymous
Not applicable

Thank you! It worked well.

FreemanZ
Super User
Super User

hi @Anonymous 

try to plot a visual with year and colour columns, and a measure like:

 

3YColourSum = 
VAR _year = MAX(TableName[year])
RETURN
SUMX(
    FILTER(
        ALL(TableName),
        TableName[Colour] = MAX(TableName[Colour])
            &&TableName[Year] IN {_year, _year-1, _year-2}
    ), 
    TableName[Sales]
)

 

it worked like:

FreemanZ_0-1675662926487.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.