Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
george31
Regular Visitor

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
1 ACCEPTED SOLUTION

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
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.

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



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks very much @parry2k .

Very simple solution.

Another thing I had to do is use the Calendar[Date] in my table/matrix rather than I had used the TRC[Date] which seem to show extra info but no matter.

Appreciate your quick precise help!!

 

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors