Variable conditional formatting rules
Last updated
Last updated
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.
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.
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.
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.
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.
Watch the variable rules in action when we switch between data from different years: