Forum Discussion
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):
| Queue | Date | Answered |
| IT Help | Mon 2 March 2020 | 47 |
| IT Help | Tue 3 March 2020 | 45 |
| Customer Service | Mon 2 March 2020 | 707 |
| Customer Service | Tue 3 March 2020 | 578 |
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
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
- george31Regular Visitor
Correction: formulae should have been <= [Selected Date]
Have also tried
CALCULATE(SUM(TRC[Answered]), FILTER(TRC,TRC[dateYearWeek] = [Selected YearWeek]))andCALCULATE(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.