Advanced controls

How to create a metric selector to control which measure is displayed in your set of Looker Studio charts

How to create a metric selector to control which measure is displayed in your set of Looker Studio charts

Let’s go back to the basic to create a simple metric selector. This allows to change the measure displayed inside a set of Looker Studio charts (formerly known as Google Data Studio) as report reader.

Taking of avantage of a simple configuration, this kind of control gets a lot of benefits and can be implemented for various reasons:

  • Displaying the main metric is your concern but the same charts can be useful for secondary measures (basically, optional metrics, shared across more than one chart)
  • You don’t want to overload your report with chart sets, replicated for each metric
  • 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, measure 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 dimension selector. The related article needs to be updated for minor changes (no more parameter value wrapper to use it as part of a calculated field) but the main part is still relevant.

Inspiration & data sample

Of course, you can follow this tutorial for any list of metrics, available in one of your data source or blended data.

In my case, I’ve decided to use this opportunity to see how Looker Studio could address subjects about time-series analysis for correlation findings. I was inspired by the conference of Tim Wilson at Superweek 2023. He explained how we can analyze & educate, with accessible calculation technics, to confirm/deny speculations about temporal correlations, too often quickly validated by basic parallel trends: “Time-series analysis: Important concepts, handy techniques & some cautionary tales”. Nice sharing, as usual.

So, I built a use case to implement a part of Tim talk.

My data set includes store metrics: Let’s a shop owns a Google My Business file, receives calls for quotation, and sells products. To communicate about promotions, this store sends phone notifications to their customers & leads.

I would like to see the timing correlation of the notifications with my store metrics but there is no technical link between separate data systems (offline for most of them), except the timing of course (date as unique dimension).

The metrics have been gathered on a simple BigQuery table and they are ready for visualisation through Looker Studio.

The result

Let’s see the result before jumping to the configuration of our drop down menu (or an open fixed-size control) to choose the metric we wish to display in our charts.

Example of data set

Any set of metrics is compatible with the metric selector, even for automatic aggregated metrics (blue fields in the data source).

In my case, I stored and prepared this data set through a BigQuery query. You will find below a screenshot of the data set sample.

Data set for Looker Studio metric selector

The columns of “first difference” (the subtraction between the value of the current row and the value of the previous row, so the day before in our data set) are made for the scatter chart (third chart in the demo). For your information, one of the limitation of Looker Studio for this kind of analysis is the management of analytical & running calculation in general:

  • There is no function (just UI field options at chart level)
  • Running calculation like delta is available only for displayed metrics, not for sorting data set (not consistent for scatter plot)
  • This kind of calculation are limited (no rate of previous row as example)

Data source parameter

First, we recreate a parameter “Metric” in the data source and configure it as a list of text values, with metric names as values and labels.

Parameter to configure for Looker Studio metric selector

Calculated fields

Then, we add a calculated field “Selected metric” in the data source to map the value selected through the parameter, with the right field corresponding to the metric. A simple CASE statement.

Calculated field for selected metric in Looker Studio

(optional) I’ve made also a second calculated field for first difference metrics regarding my example, to use it especially for the third chart.

Calculated field for selected metric first difference

Charts update

Now, update your charts to replace the hard configured metric with “Selected metric”, so the calculated field we just created. In my example, I’ve also adapted the chart legend to indicate the name of selected metric as part of a custom legend (a one-row table using the same tricks described in a previous article).

Drop down or fixed-size control

At last, I drag and drop the parameter “Metric” from the data tab to the zone of the Looker Studio report page. It would create a drop down menu you can customize. So now, everything is ready to test the interactive report mechanism changing the value of the metric selector and checking that the charts are updated with the wished measure.

Configuration review

Quite easy. Let’s review the full implementation with the video below.