Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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