Forum Discussion

abc_777's avatar
abc_777
Solution Specialist
5 years ago
Solved

dynamic days

Dear Concern,   I have total sales and calendar table   I can do previous month sale or last 30 days sale   but these are static values I need dynamic date value. mean user can put last any nu...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi abc_777 

    Please correct me if I wrongly understood your question.

    Take 'Calendar Date'[Date] as the standard, and then calculate the date of the previous few days . I've taken the previous three days as an example .

    Sum last 3 days = CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[Date]>CALCULATE(MAX('Calendar Date'[Date])-3) && 'Table'[Date]<=MAX('Calendar Date'[Date])))

     

    Original data :

    The effect is as shown:

     

    Best Regards

    Community Support Team _ Ailsa Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.