Hello, in the date format, I have configured my charts in ISO Week and Year, everything looks fine. But I would like my ISO Week to start on Sunday. Can anyone help me?
Hi @OmarTox ,
Youāll need to create a new calculated field in order to do this. You can see the solution here
Thank you for your query!
Please try the following option:
-
concat(cast(Day as NUMBER) - weekday(Day)," | ",cast(Day as NUMBER)-weekday(Day)+6)
-
In your underlying dwh, create a custom calculation similar to: DATE_TRUNC(DATE(timestamp), WEEK(SUNDAY)) which is BigQuery syntax
When you say āday as NUMBERā and āDayā in this formula, how do you input that into the actual formula? I keep getting syntax errors.
Also, itās curious. Google Sheets has a weeknum function that starts on Sunday, but LookerStudio week function starts on Monday, why not just add a weeknum function that starts on Sunday to Lookerstudio?
I had issues implementing what the others suggested, (@slater your āsolution hereā link is broken). Hereās what I did.
-
Switch your chart to āLine chartā (not Time-series). This is represented by an icon with two lines (red & blue).
-
Add a calculated field to your data source with the formula below. In the example, start_date is a date field representing the starting Sunday for the data point. Name it ādate_rangeā
FORMAT_DATETIME(ā%Y-%m-%dā, start_date) || " to " || FORMAT_DATETIME(ā%Y-%m-%dā, DATETIME_ADD(start_date, INTERVAL 6 DAY))
- In your chart config, set the Dimension to ādate_rangeā. Set Sort to date_range and Ascending. This is very important!
This link is broken. I am very interested in the solution as I have Looker Studio data Iād like to display starting on a Wednesday.
I tried this but it looks like it is setting the range to the last few days dependent on the day you are viewing the data, not a solid day of the week. Iām looking for a solution for a manual data update that only updates on a Wed-Tues range and this looks like it works if I view it on a Wednesday but Iād like to be able to make it every Wednesday.
@AndrewM1982 ah I can see that. While I havenāt tested it, I think a solution would be to truncate the start_date to the desired day of week.
Hereās a link to the date functions, see DATE_TRUNC https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_trunc
If Iām understanding your use case, you could replace instances of start_date in my previous reply (step 2) with DATE_TRUNC(start_date, WEEK(WEDNESDAY))
Iām interested in hearing if that works for you!
Thanks for trying but it doesnāt look like Looker Studio has DATE_TRUNC enabled, only DATETIME_TRUNC. https://support.google.com/looker-studio/answer/9729685?hl=en
hi, from my side, this calculation only showing daily, can i make it weekly grouping starting, the example is 6 - 12 oct?
Iām not sure if this is overkill, and there is probably a more sleek way to achieve this, but I was able to get this to work using the following formula. This gave me weeks defined as Sunday - Saturday, and āDateā is the field that I am trying to translate into a Sun-Sat week timeframe.
FORMAT_DATETIME(ā%Y-%m-%dā, DATETIME_ADD(Date, INTERVAL -1*WEEKDAY(Date) DAY)) || " to " || FORMAT_DATETIME(ā%Y-%m-%dā, DATETIME_ADD(Date, INTERVAL 6-WEEKDAY(Date) DAY))
For each date, you figure out what day of the week it is and then subtract the appropriate amount of data to figure out the Sunday the week starts on, and add the appropriate amount of days to figure out the Saturday the week ends on.