Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

previous day total

I woulk like to calculate a total for the previous day, so today minus 1 - with the caveat I would like to onlly count workdays... So on monday the previous days total is from Friday?

  • Hi jtbold2,

     

    You mean to calculate the previous day's values, but for Monday, all values from Friday onwards

    Creating the underlying data like this:

     

    1 Create a measure

    Total =

    var _2345=CALCULATE(SUM('table'[value]),FILTER('table','table'[date]=TODAY()-1))

    var _1=CALCULATE(SUM('table'[value]),FILTER('table','table'[date]=TODAY()-3))

    return

    IF(WEEKDAY(TODAY(),2)=1,_1,IF(WEEKDAY(TODAY(),2)<6,_2345,BLANK()))

     

    2 Create a card visual and put measure in card

     

     

    You can try it with my demo

     

    Best Regards

    Community Support Team _ chenwu zhu

     

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

     

     

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Yeah, so one way of doing this is to do it this way:

    Previous Work Day = 
      VAR __CurrentDate = MAX('Table'[Date])
      VAR __Calendar = ADDCOLUMNS(CALENDAR(__CurrentDate - 1, __CurrentDate - 3),"__WeekDay",WEEKDAY([Date],2))
    RETURN
      MAXX(FILTER(__Calendar,[__WeekDay]<6),[Date])
    
  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Icon for Community Support rankCommunity Support

    Hi jtbold2,

     

    You mean to calculate the previous day's values, but for Monday, all values from Friday onwards

    Creating the underlying data like this:

     

    1 Create a measure

    Total =

    var _2345=CALCULATE(SUM('table'[value]),FILTER('table','table'[date]=TODAY()-1))

    var _1=CALCULATE(SUM('table'[value]),FILTER('table','table'[date]=TODAY()-3))

    return

    IF(WEEKDAY(TODAY(),2)=1,_1,IF(WEEKDAY(TODAY(),2)<6,_2345,BLANK()))

     

    2 Create a card visual and put measure in card

     

     

    You can try it with my demo

     

    Best Regards

    Community Support Team _ chenwu zhu

     

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