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
athomp15
Helper I
Helper I

Rolling total based on date -20 days

Hi All,

 

I'm struggling to work out (so seeking help for) a Power Query or DAX Calc, to work the maximum sales value is for each Employee based on a 20 day rolling period.  The data table is shown below.  So for Employee 1, it would be dates 27/01/2018 and 14/02/2018 with a total sales for 120000

 

Employee, Date, Sales

Employee1, 20/01/2018,10000

Employee1, 27/01/2018,30000

Employee1, 14/02/2018,90000

Employee1, 11/03/2018,50000

Employee1, 19/03/2018,20000

Employee1, 20/03/2018,4000

Employee2, 20/01/2018,2000

Employee2, 22/02/2018,3000

Employee2, 24/02/2018,60000

Employee2, 07/03/2018,50000

Employee3, 28/02/2018,1000

Employee3, 20/03/2018,70000

 

Thanks in advance

Alex

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @athomp15,

 

Try the formula below.

 

Rolling 20 days =
CALCULATE (
    SUM ( Sales[ Sales] );
    FILTER (
        ALL ( Sales[ Date] );
        Sales[ Date]
            >= MAX ( Sales[ Date] ) - 20
            && Sales[ Date] <= MAX ( Sales[ Date] )
    )
)

 

Rolling_sum.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
athomp15
Helper I
Helper I

Works Perfectly MFelix, 

 

Many thanks

Alex

MFelix
Super User
Super User

Hi @athomp15,

 

Try the formula below.

 

Rolling 20 days =
CALCULATE (
    SUM ( Sales[ Sales] );
    FILTER (
        ALL ( Sales[ Date] );
        Sales[ Date]
            >= MAX ( Sales[ Date] ) - 20
            && Sales[ Date] <= MAX ( Sales[ Date] )
    )
)

 

Rolling_sum.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.

Top Solution Authors
Top Kudoed Authors