I want to create a command to choose the Time frame: current week, last week, current month, last month, rolling 7 days, 30 days, 90 days in Looker Studio.
I wasn't able to do it easily. So I created a calculated field with this formula:
CASE
WHEN EXTRACT(WEEK FROM date) = EXTRACT(WEEK FROM CURRENT_DATE()) THEN "Current Week"
WHEN EXTRACT(WEEK FROM date) = EXTRACT(WEEK FROM CURRENT_DATE()) - 1 THEN "Last Week"
WHEN EXTRACT(MONTH FROM date) = EXTRACT(MONTH FROM CURRENT_DATE()) THEN "Current Month"
WHEN EXTRACT(MONTH FROM date) = EXTRACT(MONTH FROM CURRENT_DATE()) - 1 THEN "Last Month"
WHEN DATE_DIFF(CURRENT_DATE(), date) <= 7 THEN "Rolling 7 Days"
WHEN DATE_DIFF(CURRENT_DATE(), date) <= 30 THEN "Rolling 30 Days"
WHEN DATE_DIFF(CURRENT_DATE(), date) <= 90 THEN "Rolling 90 Days"
END
When I create my command using this field, only last week, rolling 90 days, and last month are displayed. How can I fix this?
(I'm on Looker Studio, not Looker Studio Pro)
The possible solutions about this topic depends closely to the data source type. Some tricks exist for BigQuery or Sheets data sources, but it is quite impossible to do what you describe with GA4 with API connectors (like Google Analytics or Ads).
So first, what kind of data sources are loaded in your report?
Thanks for your comment @Mehdi_Oudjida
I'm currently using GA4 joined with sheet so yes, maybe that's not possible here.
I'm using only a sheet for another dashboard so i'm interested in the tricks.
And we will maybe use Bigquery after.
You can make a tiny test with Google Sheets: You need to remove the date range dimension from the configuration of the chart (a date field from the data source is selected by default).
Then you will completely control all the data of your source. Of course, it is not recommended to do it with huge data sets.
For BigQuery, using custom queries data sources, combined to parameters, it gives a lot of possibilities of control. Here an article with a mechanism of custom date range comparison I designed.
L'article est aussi disponible en français, si tu préfères.
Espérant que cela t'aide.
Mehdi
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 |