Forum Discussion

Lynzmaz's avatar
Lynzmaz
Regular Visitor
4 years ago
Solved

Previous weekly sales

Hi there,

I need a column with the previous weeks sales. The current week measure is working well but the previous week is not working. What am I doing wrong?!?

Sales This Week = CALCULATE(sum('2019'[Net Sales]),FILTER(ALL('2019'),'Calendar'[WeekRank]=MAX('Calendar'[WeekRank])))
Sales Last Week = CALCULATE(sum('2019'[Net Sales]),FILTER(ALL('2019'),'Calendar'[WeekRank]=MAX('Calendar'[WeekRank])-1))
WeekRank = RANKX(All('Calendar'[Date]),'Calendar'[WeekStartDate],,ASC,Dense)
WeekStartDate = ('Calendar'[Date]+-1*WEEKDAY('Calendar'[Date],2)+1)
 
Thanks so much!
Lyndall
  • Hi Lynzmaz 

    You can try this, create the measures below. For more please see sample file attached below

    ThisWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])))
    LastWeek = CALCULATE(SUM('2019'[Net Sales]),FILTER(ALL('2019'),RELATED('Calendar'[WeekRank])= MAX('Calendar'[WeekRank])-1))

    result

     

    Best Regards,

    Community Support Team _Tang

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

2 Replies