Forum Discussion

joshua1990's avatar
joshua1990
Post Prodigy
6 years ago
Solved

WTD for current Week

Hello everyone! This measure sums upp all sales for the last/ max week of selected month:   Sales WTD = CALCULATE ( [Sales], FILTER ( ALL ( 'Calendar' ), 'Calendar'[Fisca...
  • Greg_Deckler's avatar
    Greg_Deckler
    6 years ago

    joshua1990 - It might be but this is part of the reason I don't tend to use CALCULATE because it runs into difficulties once variables and stuff get involved or you start to do anything even remotely complex. Seems like maybe you could add a filter statement for that CALCULATE that did some magic I suppose using TODAY function (if that is how you define "current") so like

     

    'Calendar'[Fiscal Year] = YEAR(TODAY()) for example. 

     

    You can use WEEKNUM to get week number and you would also need to use WEEKDAY to get days in the week prior to the current day of the week (in order to get WTD). I've solved this whole thing a number of times in various posts but I don't do it with CALCULATE. Not saying it is impossible but I don't do things that way unless I am forced to because it is fraught with complexities.

     

    Anyway, I wrote an entire blog article about why dealing with CALCULATE is a big PITA.