Forum Discussion

george31's avatar
george31
Regular Visitor
6 years ago
Solved

Problems calculating week to date from selected date

I am trying to calculate the WTD (week to date starting on Mondays) and MTD / YTD figures on a table where person can select the date to base this on.

It would seem it should be fairly easy as we want to sum the field for all records where the week number matches the week number of the selected date but I can't seem to get the filtering correct.

My base table TRC which has data in it is (first row is the column names):

QueueDateAnswered
IT HelpMon 2 March 202047
IT HelpTue 3 March 202045
Customer ServiceMon 2 March 2020707
Customer ServiceTue 3 March 2020578

This data has already been summarised for simplicity (in actual fact there may be a number of records for same queue/date.

 

There is also a date table which has each unique date which links/related to this table and is used for selection.

Both tables have extra columns with calculated YEAR(date) * 100 + WEEKNUM(date) so that I can restrict data. In above example it returns 202010.

 

What I need is when the user selects Mon 2nd then get:

IT Help with WTD of 47

Customer Service WTD = 770

If Tue 3rd selected then get:

IT Help WTD = 92

Customer Service WTD = 1285

 

The user can also select a specific queue so will only see data related to that.

 

I am having trouble keeping the selected date as well as filtering by same date field to get WTD (and presumably MTD/YTD figures).

 

Have tried 

CALCULATE(SUM(TRC[Answered]), FILTER(ALL('Calendar'),'Calendar'[Date] = [Selected Date]))
plus other combinations but can't reference the weeknum fields in this case.
 
Any help appreciated.  Understand this is a bit cryptic but hopefully I can be put in the right direction.
Cheers
  • george31 see attached, there are many tables, for you, just look at customer service  and calendar table  and measures in Customer Service table

     

    Would appreciate Kudos 🙂 if my solution helped.

4 Replies

  • george31's avatar
    george31
    Regular Visitor

    Correction: formulae should have been <= [Selected Date]

     

    Have also tried 

    CALCULATE(SUM(TRC[Answered]), FILTER(TRC,TRC[dateYearWeek] = [Selected YearWeek]))
     
    and 
    CALCULATE(SUM(TRC[Answered]), FILTER(ALL('Calendar'),'Calendar'[calYearWeek] = VALUES('Calendar'[calYearWeek]) && 'Calendar'[Date] <= MAX('Calendar'[Date])))
     
    but none seem to give correct result and always seem to return the SUM(Answered) for selected day.
    • parry2k's avatar
      parry2k
      Super User

      george31 so you want Week To Date total by each queue and week starting Monday, correct?

      • parry2k's avatar
        parry2k
        Super User

        george31 see attached, there are many tables, for you, just look at customer service  and calendar table  and measures in Customer Service table

         

        Would appreciate Kudos 🙂 if my solution helped.