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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.