How to build a parameter to switch between day, week or month in Looker Studio?
Ever wondered how to build a magic button to switch between day, week or month in Looker Studio? Search no more, we’ve got a solution !
Ok, you know the drill on your dataviz, shall it be a table, a time serie or a line graph: add a Drill down and you’ll be able to switch between day, week or month. But this is only applicable to one dataviz at the time, right? What if you wanted to change ALL your dataviz, at once? Well, in this article, we’ll show you how to a build a parameter to switch between day, week or month in Looker Studio. Pretty easy, whilst pretty powerful at the same time. Best of both worlds.
Top Looker Studio connectors we love and use on a daily basis (all with free trials): PMA - Windsor - Supermetrics - Catchr - Funnel - Dataslayer. Reviews here and there.
Not sure which one to pick? Have a question? Need a pro to get a project done? Contact us on LinkedIn or by e-mail, and we’ll clear up any doubt you might have.
Let’s start with creating the parameter
First, let’s create a new parameter for your data source. Proceed to Resource on the top ribbon, Manage added data source, Edit and then Add a parameter top right corner. We’ll call it toggle, and provide 3 levels for List of values: Day, Week, Month, with Day being the default:
Save your parameter, and let’s move on to the new dimension.
Create a new dimension as a field
Back to the Field page, now Add a field, let’s call it New Date and copy the below formula:
CASE
WHEN toggle='Day' THEN date
WHEN Toggle='Week' THEN CAST(DATETIME_TRUNC(date,ISOWEEK) AS DATE)
WHEN Toggle='Month' THEN CAST(DATETIME_TRUNC(date,MONTH) AS DATE)
ENDSo, how will it work? When you’ll change the value of the Toggle using a control, the value of your New Date field will change according (we’ve played with dates here, but remember that this can be applied to loads of use cases. Also, to ensure to always have the same DATE format, we used a CAST: indeed, DATETIME_TRUNC returns DATETIME ^^).
So, what do we do next?
Build 2 dataviz, let’s say a table and a line chart, with our newly created New Date field as a dimension. Create a control based on our Toggle parameter.
And that’s pretty much it! Change the toggle value, and it will change the date dimension on all associated dataviz:
In this article, we’ve reviewed how to build a parameter to switch between day, week or month in Looker Studio.
PROBLEM SOLVED
Top Looker Studio connectors we love and use on a daily basis (all with free trials): PMA - Windsor - Supermetrics - Catchr - Funnel - Dataslayer. Reviews here and there.
Not sure which one to pick? Have a question? Need a pro to get a project done? Contact us on LinkedIn or by e-mail, and we’ll clear up any doubt you might have.
Communicate and browse privately. Check Proton Mail and Proton VPN
Website hosted by Tropical Server


