The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Thank you in advance for any help you can give me! I always struggle with time intelligence 🙂
My data is laid out in the following format:
Date submitted | Start of week | End of week |
28/8/23 | 28/8/23 | 3/9/23 |
27/8/23 | 21/8/23 | 27/8/23 |
I've been trying to count using the below measure:
Measure = countrows(table)
I need to count the number of complaints for the last week (excluding the current week) then an 8 week total and a ytd total.
This formula comes up blank:
I have a date table that is linked to a submitted date so the [end of week] and [start of week] both have hierachies.
I've also played around with two sets of dateadd in the above formula:
DATEADD(__LAST_DATE, -7, DAY),
DATEADD(__LAST_DATE, 0, DAY),
...but it's either coming up blank or isn't adding up correctly.
I've also tried with the weeknum but I haven't been able to work it out.
Solved! Go to Solution.
Hi @AmiraBedh,
Appreciate you putting a solution online for me.
I managed to work it out in a different way (posting online for others).
Created:
Hi @AmiraBedh,
Appreciate you putting a solution online for me.
I managed to work it out in a different way (posting online for others).
Created:
I am breaking down your issue in 3 parts :
1. **Last Week Total**: Count the number of complaints for the last week (excluding the current week).
2. **8-Week Total**: Count the number of complaints for the last 8 weeks (including the last week).
3. **YTD Total**: Count the number of complaints year-to-date.
Based on the table structure you shared :
**1. Last Week Total**:
Last Week Total =
VAR LastDateInData = MAX('hotjar'[End of Week])
VAR StartOfLastWeek = LastDateInData - 7
RETURN
COUNTROWS(
FILTER(
'hotjar',
'hotjar'[End of Week] <= LastDateInData && 'hotjar'[End of Week] > StartOfLastWeek
)
)
**2. 8-Week Total**:
8 Week Total =
VAR LastDateInData = MAX('hotjar'[End of Week])
VAR StartOf8WeeksAgo = LastDateInData - 56
RETURN
COUNTROWS(
FILTER(
'hotjar',
'hotjar'[End of Week] <= LastDateInData && 'hotjar'[End of Week] > StartOf8WeeksAgo
)
)
**3. YTD Total**:
This will use your date table linked to the submitted date:
YTD Total =
VAR TodayDate = TODAY()
RETURN
COUNTROWS(
FILTER(
'hotjar',
'hotjar'[Date submitted] <= TodayDate && YEAR('hotjar'[Date submitted]) = YEAR(TodayDate)
)
)