Today the extract() function does not support extracting the ‘week number’ from a date field. As a workaround you can use a formula like this (may need some adjustments +/-1 for certain years, could add some ifElse logic to account for that). FYI this uses weeks starting Sun.
Hi Jesse, thanks for providing this solution! Is there a way to get the week to start on Monday? I have had some trouble in the past with trying to align Quicksight with data from Athena, which does not have support for weeks starting on Sunday.
Presto documentation %V Week (01 … 53), where Sunday is the first day of the week; used with %X
The following specifiers are not currently supported: %D %U %u %V %w %X https://prestodb.io/docs/current/functions/datetime.html
→ move each date to the beginning of the week, Sunday (works on the edge of the year)
→ add 6 days to move it to last day of the week, Saturday (gets the year back for the edge cases)
This way you have nice grouping per “last day of the week”, but you can add weeknum() (not documented function) to get the number
Thanks a ton. The fact it was posted in 2021 and still we have to use this shows how an important function like getting week num is hard in Quicksight. Hope developer teams notice this.