Use conditional formatting rules in Data Studio

Display your data in different colors according to conditions you define.

You can style the data in your charts based on certain conditions. For example, if Campaign is "Summer Sale," then set the entire table row font color to green, or if Sales is less than Forecast, set the scorecard background color to red.

  1. Edit your report.
  2. Select a supported chart (see the limits section below).
  3. On the right, click STYLE.
  4. At the top, in the Conditional formatting section, click + Add.
  5. Define the format rules.
  6. Define the color and style to apply when the format rules are met.
  7. Click Save.

Conditional formatting demonstration

In this article:

How conditional formatting works

Conditional formatting evaluates one or more format rules and applies color and style to the fields in your chart that satisfy those rules. Currently, you can apply these rules in tables and scorecards.

If you switch a chart's visualization to a different type (for example, a table to a scorecard), conditional formatting will continue to work as long as the fields and values used in the formatting rules still exist in the new chart. Rules based on fields or values that aren't in the new visualization are ignored.

Create format rules

Format rules are comparison conditions that determine when to apply different color and style. You can compare a single field in the chart to a literal value (for example, Campaign = Summer Sale), or to another field (Actual Sales < Forecast Sales). Format rules can only use fields currently contained in the chart.

Rule comparison operators

The comparison operators available depend on the type of field you're comparing to. For example, if you select a numeric field, you can use operators such as:

  • Equal to
  • Not equal to
  • Greater than
  • Less than or equal to
  • etc.

For text fields you can create conditions using:

  • Equal to
  • Empty
  • Not empty
  • Contains
  • Regex
  • etc.

For Boolean (logical) fields, you can also use:

  • Is TRUE
  • Is FALSE

Format rule order

The order in which you specify format rules can be important. Multiple rules in a chart are evaluated in descending order, and the last set of true conditions found is the one that is applied. For example, say you've got three rules in a table:

  • Rule 1 sets both the font color and background color.
  • Rule 2 sets the font color.
  • Rule 3 sets the background color.

When all 3 rules are true, you'll get the font color from rule 2 and the background color from rule 3. Rule 1 will be ignored, as shown below:

Rule order example 1

You can reorder rules using the drag bars on the left. Here's what happens when we move rule 3 to the top:

Rule order example 2

In this example, the background color from rule 1 carries through the following rules and is applied to the table.


Format rules, percentages, and decimal precision

When building rules that compare numbers, be sure to use the actual value in the data, rather than the value displayed in charts. For example, to build a format rule that selects values greater than 51.2%, use the decimal value:
Bounce rate > .512
Similarly, numbers displayed in your charts may be rounded up or down. Be sure to include as many digits as necessary in your rule to properly match the underlying data. For example, a rule such as Bounce rate = .512 wouldn't apply if the actual value was .5119, even though that number appears as .512 when rounded to 3 decimal places.
You can adjust metric decimal precision in the chart's STYLE tab.

Select any field

To build a condition that returns true if any field in the chart matches your rule, click Select a field, then click Select any field.

Format rules showing Select any field option,.

  1. Select any field.

When this option is selected, the format rule displays "Values," indicating that the rule applies to any values found in the chart.

For scorecards, this is the only option available.

Set color and style

Color and style rules determine which data to format and how to format it. You can format the entire table row, a specific field value, or any value that matches, regardless of which field it occurs in.

Format the entire row

The Entire row option applies the format to every row in the table that matches the condition.

For scorecards, this option appears as Cells, and is the only option available.

Format a specific field

You can format a specific field in a table. Click the field selection drop-down menu and select the field you want to format.

Color and style example

Format cells

The Cells option applies to scorecards, and to rules using Select any field in a table. This option applies the color and style to the scorecard metric, or to the values that match the table's format rule.

Edit and delete rules

  1. Edit your report.
  2. Select the chart with the rule you want to edit.
  3. On the right, Click STYLE.
  4. At the top, in the Conditional formatting section, click Edit Edit, then for the rule you want to change, click Edit Edit or RemoveRemove.

Copy conditional formatting rules

There are 2 ways to duplicate conditional formatting rules:

  • Copy and paste a chart with conditional formatting to create a new chart with those same rules.
  • Copy a chart with conditional formatting, then use Edit > Paste special > Paste style only to apply that chart's conditional formatting to an existing chart.

Limits of conditional formatting

  • Conditional formatting is currently available for tables and scorecards.
  • You can have up to 10 format rules per chart.
Was this helpful?
How can we improve it?