Forum Discussion

Uzi2019's avatar
Uzi2019
Community Champion
3 years ago
Solved

Incorrect Prev week value

Hi Community,

I need to calculate prev week spend which I tried from my end but at the measure total getting wrong result. Attaching sample data and screen shot below:

SpendDate
1201-Jan-2023
1302-Jan-2023
1503-Jan-2023
1204-Jan-2023
1105-Jan-2023
906-Jan-2023
567-Jan-2023
588-Jan-2023
369-Jan-2023
9010-Jan-2023

 

 

 

 

Prev Week Spend = 
VAR MaxWeek = MAX('Calendar'[WeekNo.])-1
VAR PrevWeek =  CALCULATE(SUM('Table'[Spend]),
                            FILTER(ALLSELECTED ('Calendar'),'Calendar'[WeekNo.]=MaxWeek
                            )
                         )

 

RETURN PrevWeek

 

Can anyone please help me out? It's quite urgent.
I would really appreciate your help

 

 

  • Hi,

    try  a measure like this

    Measure = CALCULATE(sum('Table (2)'[Spend]), OFFSET(-1,ALLSELECTED('Invoked Function'[ISOWeekID])))

    If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

2 Replies

  • Hi,

    try  a measure like this

    Measure = CALCULATE(sum('Table (2)'[Spend]), OFFSET(-1,ALLSELECTED('Invoked Function'[ISOWeekID])))

    If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

    • Uzi2019's avatar
      Uzi2019
      Community Champion

      serpiva64 Thanks a bunch buddy. It's now working as per your given measure.