How to add a dimension selector to control dynamically which data is displayed in your Looker Studio charts
Let’s go back to the basic to create a simple dimension selector. This allows to give the control to report readers, changing the dimension displayed inside a chart or set of Looker Studio charts.
Taking of avantage of a simple configuration, this kind of control gets a lot of benefits and you can implement it for various reasons:
- Loading the main dimension is your concern but the same charts can be useful for secondary dimensions
- You don’t want to overload the content of your report with chart sets, replicated for each dimension
- Your chart configuration is quite sophisticated and parameter variables are enough to not repeated elements, easier to maintain in the future
- You need to reduce the number of data requests, and so, what is not loaded when the page is displayed is also what will not affect costs or quotas, data requests just on demand
- It is more an exploration tool. You know how to display data but not what
- …
The same principle is also possible with a metric selector, described in another blog post.
Ingredients to build the dimension selector:
- A new parameter in your existing data source
- A calculated field
- A drop-down list control
- A change of dimension in your existing charts (a table chart in my example)
For this recipe, I’ve decided to not use the “dimension control” – the built-in solution of Looker Studio for a dimension selector – because it is very limited in terms of customization.
The result: The dimension selector in action
Let’s watch a demo of the finished report before going through this tutorial to give the control to report readers and allow them to choose the dimension they wish to display.
Example of data set for the dimension selector
Any set of dimensions is compatible with the dimension selector. In my case, I stored in BigQuery a data set of e-commerce orders by country, device type, operating system and browser.
Data source parameter
First, we create a parameter “Dimension” in the data source and configure it as a list of text values, with dimension names as values and labels. For my example, “Country” is the default selected value.
Calculated field “Selected dimension”
Then, we add a calculated field “Selected dimension” in the data source to map the value selected through the parameter, with the right field corresponding to the dimension. A simple CASE statement.
Selected dimension
CASE Dimension
WHEN "Country" THEN Country
WHEN "Device Type" THEN Device Type
WHEN "Operating System" THEN Operating System
WHEN "Browser" THEN Browser
END
Chart update to include the selected dimension
Now, update your charts to replace the hard configured dimension with “Selected dimension”, so the calculated field we just created.
The drop-down list control as the dimension selector
At last, I add the parameter “Dimension” as a drop-down list control. In my example, I put the control over the dimension header but off course, you can put it aside.
Now, the dimension selector is in place and can be tested, changing the value of the control and checking that the chart is updated with the wished dimension values.
Configuration review
Let’s review the full implementation with the video below.
Final thoughts
The mechanism of control described above can also be applied for a secondary dimension selector. The first version of this article was describing the same solution with this prism of implementation: Reproducing the secondary dimension selector of Google Analytics Universal. The only difference is the presence of additional hard-configured dimension column in a table chart, the configuration itself is easy as we see with a single dimension selector.
Voilà.