Variable conditional formatting rules

Variable Conditional Formatting is a feature that allows you to apply conditional formatting rules to elements that are not directly linked to specific data points. This can include altering the line color, specific parts of your title, x-axis, and y-axis titles. By using variables, you can combine multiple rules and apply them together, enabling more advanced formatting on non-data elements.

With variables, you can reuse the same conditional formatting rules and apply them to different elements. Let's see how.

STEP 1: Define the conditional formatting rule and select the color to be applied when the condition is met. Remember to enable the Use as variable toggle.

Define the conditional formatting variable

STEP 2: You can combine multiple conditions with variables. For example, if sales > average sales, set the color to red; if sales < average sales, set the color to green. When you combine conditions, ensure that all the rules have the same variable ID.

Use the same variable ID to combine multiple CF rules

STEP 3: To use the variable to change the font color of the x-axis title, open title settings > color picker. Navigate to the CF Rules tab and select the variable to apply.

Using variables to change the x-axis title color

STEP 4: Use variables to drive the color of the header. Just like we did for the x-axis title, select the variable from the CF Rules tab of the color picker.

Using variables to apply conditional formatting to the header

STEP 5: Change the color of line charts with conditional formatting the same way - select the variable from the Category format color picker in Canvas settings.

Using conditional formatting variables to change the color of line charts

Watch the variable rules in action when we switch between data from different years:

CF rules for variables

Last updated