Conditional Content Component for Google Data Studio

Looker Studio Masterclass, my advanced & premium course, is now publicly available. 100% for free!

No signups, upsell funnels, order bumps, or nonsense!

Access here >>

Ahmad Kanani

Introduction

Have you ever wanted to add a warning text or a simple traffic light signal to your KPI reports in Data Studio, where Revenue, Conversion Rates, etc. are above or below the target? 

What about adding a green checkmark at the top-right corner of the dashboard if everything is within the expected range?

Something like this:

Notice that in the above example, the signals change as revenue decreases below $5k.

If you’ve ever tried to output a string of text, or god forbid an emoji, based on a numerical comparison such as the scenarios listed above, you know that it’s almost impossible to achieve using the standard features of Google Data Studio.

Performing the same, based on operations on text values is possible with a simple CASE function such as:

CASE
  WHEN Country IN (“USA”,”CANADA”) THEN “North America”
  WHEN Country IN (“Germany”,”France”) THEN “Europe”
  ELSE “Others”
END

But it is not possible when using logical operations on metrics, for example, the CASE function below will result in an error:

Basically, if the logical operation after the WHEN clause is done on a number, then the returned value of the THEN clause should be numeric too, same with strings.   

On the other hand, the current conditional formatting feature in Data Studio is limited to the font and background color of scorecards and tables only.

In this article, I’m going to introduce a community component that we’ve recently released, which allows you to show different pieces of content based on numerical ranges or even show or hide the component based on different metric ranges.

Use Case Examples

Being able to return a string value based on a simple numeric operation can be very useful, helping you better communicate insight with the audience of your reports.

Some examples of ways this feature can be used to improve reports are:

Adding automatic insights to the reports based on expected performance

Check against a metric and output different content in a text box based on whether the metric meets or exceeds target or performs worse than expected.

Drawing attention to specific KPIs using a traffic light signal

Show an amber, a green, or a red icon if a metric falls within specific ranges

Changing chart titles based on different criteria

Add a dynamic chart title that changes according to the values of the metric represented in the chart.

Use visuals to show performance against goals/targets.

Use visual signals like X or Checkmark, thumbs up/down, happy neutral sad face to indicate the performance of a metric against a target.

Quickly drawing viewers’ attention to the areas of the report which require action.

Add optional elements such as text or icons to the report which are hidden by default and are only shown once a metric meets some criteria 

Installation & configuration of the component

To install and use the Conditional Content community component, you first need to add it to your report through Community Visualizations menu:

To do that, first, click on Community Visualizations Icon and then click +Explore More.

Choose the first option “Build Your Own Visualization”

Enter the component’s Manifest Path and click Submit

Click Conditional Content by Siavak.com to add it to your report.

Then place the component on the report canvas and head over to the Style tab to add the content and configure the component. Here you can:

  1. Choose the default content to be displayed when the metric doesn’t fall within any of the ranges. You can choose the font and add inline CSS to style your text just like you would configure the Google Fonts component.
  1. Add a data source and a metric to be used for the criteria defined in the next step.
  1. Define up to five numeric ranges based on which the component will show different content by first enabling the range, then entering the minimum and maximum values for the metrics range, and finally entering the content to be displayed alongside its color.

Special characters are supported in the content field (e.g., ●, ■, ♥, ▲, ▼, etc.). To get a list of these, on windows click start, type charmap, and hit enter. On a Mac, it should be accessible by pressing Command+Option+T.

Emojis are supported too and can be copy & pasted from an emoji website like getemoji.com 

Plus, you can add {{metric}} wherever in the content to be dynamically replaced with the actual value of the metric. E.g., “Revenue was {{metric}} last week, which is great news!”

Some notes:

Ranges: The numerical ranges are inclusive of the minimum number and exclusive of the max, so setting it to 100 to 200 will match 100 to 199.9999 but not 200.

Hiding the Component: You can leave the content blank for any of the ranges to hide the component. It actually becomes transparent, so it still masks the interaction with the charts below it if there’s an overlap.

Range Overlaps: Ranges can overlap, although it’s not recommended. When they do, the highest range gets the highest priority in case of conflicting values. For example, the 5th range gets priority over the 1st range.

Community Visualization Access: For the component to work, the Community Visualization access at the data source level should be turned on. To do that, simply click to edit the data source and turn on Community Visualization Access:

Can you think of other use cases for this component or ideas to improve it by adding new features? Let me know below in the comments section!

Join Newsletter

Community

Join Google Data Studio Community on Facebook: share ideas, ask questions, get help from experts, and help others!

Tools

Bring your data into Data Studio, Google Sheets, and BigQuery

Learn Analytics & CRO