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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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