13.11. Dynamic Date Range Granularity Selector
The dynamic date range granularity selector allows you to change the granularity of a chart in Looker Studio without navigating to different pages or using multiple charts. This can be achieved using parameters, case functions, and controls in a creative way.
Setting Up the Dimension
First, create a dimension using a case statement. The dimension should change based on the value of a parameter. For example, when the parameter's value is 1, the dimension should display dates in a day format, and when the parameter's value is 2, the dimension should display dates in a week format, and so on.
Creating the Parameter
Create a parameter of type number with a range from 1 to 4 (or any other range based on your needs). This parameter will be used to determine the granularity of the chart.
Creating the Click Effect
To create the click effect, follow these steps:
- Add icons for each granularity level to your report (e.g., daily, weekly, monthly, and yearly).
- Place a slider control in your report, setting the opacity to 0, making it completely transparent.
- Adjust the slider control's position so that it overlays the icons, creating the appearance of clickable buttons.
When users click on the icons, they will actually be interacting with the transparent slider control. The slider control will change the value of the parameter, and the chart's granularity will update accordingly.
In the given example, a chart's granularity can be changed from daily to weekly, monthly, and yearly views without changing the URL or navigating to a different page. This is done by creatively using case statements, parameters, and controls in Looker Studio.
Remember that this technique is a clever workaround and may not be officially supported by Looker Studio. Nonetheless, it can be a useful way to create a dynamic and interactive report.
Note: The mentioned technique was developed by Mehdi Oudjida.