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 September 15. Request your voucher.
Hi
I have a facts table which is a daily snapshot of lots of rows of data. I also have my dates table (both shown below)
I am struggling to countrows of the facts table if the date added match the start of the week.
I am not interested if all the other dates fall into that week only if the date added match the start of the week.
The result I would expect from the data below would = 4 (4 x 02/11/2020)
Facts Table | |
Date Added | Trade |
02/11/2020 | X |
02/11/2020 | X |
02/11/2020 | X |
02/11/2020 | X |
03/11/2020 | X |
03/11/2020 | X |
04/11/2020 | X |
04/11/2020 | X |
04/11/2020 | X |
04/11/2020 | X |
04/11/2020 | X |
05/11/2020 | X |
05/11/2020 | X |
05/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
06/11/2020 | X |
Dates Table | ||
Dim Date | Weekstart date | Weekstart number |
02/11/2020 | 02/11/2020 | 0 |
03/11/2020 | 02/11/2020 | 1 |
04/11/2020 | 02/11/2020 | 2 |
05/11/2020 | 02/11/2020 | 4 |
06/11/2020 | 02/11/2020 | 5 |
07/11/2020 | 02/11/2020 | 6 |
08/11/2020 | 02/11/2020 | 0 |
thank you
Richard
Solved! Go to Solution.
@cottrera , not very clear. You can get start of week like
Sunday start
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Monday start
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Others refer: https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...
You can compare that with date you got and create a flag
Hi amitchandak
thank you for the reply and link to some further reading. Using this I was able to resolve the issue.
@cottrera , not very clear. You can get start of week like
Sunday start
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Monday start
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Others refer: https://community.powerbi.com/t5/Community-Blog/Any-Weekday-Week-Decoding-Date-and-Calendar-2-5-Powe...
You can compare that with date you got and create a flag
User | Count |
---|---|
65 | |
60 | |
55 | |
54 | |
31 |
User | Count |
---|---|
180 | |
88 | |
70 | |
46 | |
46 |