Question:
I know I can change the date field granularity to week in AWS Quicksight, and I can also display the date by week number. But as far as I understand, Quicksight defines the start of a week on Sunday, and I need it to be Monday.
Is there any way to start the week on Monday in AWS Quicksight?
Answer:
Here is a formula for a calculated field you can add that will group your dates by weeks starting on Mondays. You should be able just replace {date_date}
with your field name and copy/paste this into the formula box (including the newlines) and it will do the trick.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
addDateTime( 1, 'DD', truncDate( 'WK', ifelse( extract( 'WD', {date_date} ) = 1, addDateTime( -1, 'DD', {date_date} ), {date_date} ) ) ) |
This field will equal the Monday that starts the week your date falls into.
You can put this all in one line but I added the line breaks for readability.
It essentials checks if the date is on a Sunday, and moves it to the previous week and then just adds a day to the normal trunc function so that the weeks begin on Monday.