Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Previous Week Sales

Hi   Having searched extensively I know this is a question that has come up lots but I just cannot manage to get prior week sales in the format I need.  I'm trying to calculate week vs prior week p...
  • jdbuchanan71's avatar
    7 years ago

    The problem you are having with your second measure is the ALL(sales_table).  It is removing all filters (including store) that come into the calc.  What you want is ALL(sales_table[week]).  

    The calc can be made more clear using a variable.  Give this a try:

    Prior Week Sales = 
    VAR PriorWeek = SELECTEDVALUE ( Sales_Table[Week] ) -1
    
    RETURN
    CALCULATE(
        SUM ( Sales_Table[Sales] ),
        ALL ( Sales_Table[Week] ),
        Sales_Table[Week] = PriorWeek
    )