Custom Expressions for Coloring


You can use custom expressions in color schemes in a few different ways and some examples are described below. You can define an anchor point with a custom expression, or you can use expressions in rules. To get a basic understanding of custom expressions, see Custom Expressions Introduction. To learn more about using rules in color schemes, see Color Rules Overview.

Anchor points are available when coloring continuous columns in a gradient or segments color mode. A custom expression can be used to determine where the breakpoint should be.

  1. Open the menu for the anchor point by clicking on the icon, color_value_menu_icon.png.

  2. Select Custom Expression.

    Response: The Custom Expression dialog is opened.

  3. In the Available columns list, select Axis.Color, and click Insert Columns to add it to the expression.

    Comment: Axis.Color represents the column you have selected to color by and it is most of the times the only "column" in the Available columns list. In table visualizations you will have access to all columns.

  4. Specify the custom expression of your choice.

    Note: The output from the custom expression must be an aggregated value.

  5. Click OK to close the dialog.

    Response: The custom expression is added as the anchor point. An icon, color_custom_expression_icon.png, indicating that the anchor point is a custom expression, is shown in the field.

A rule functions as an exception to the rest of the color scheme and can be specified using a boolean custom expression.

  1. Go to the Colors page of the Visualization Properties dialog.

  2. Click on the Add Rule... button to the right of the color scheme.

    Response: The Add Rule dialog is opened.

  3. In the Rule Type drop-down list, select Boolean expression.

  4. Click on the custom expression icon, color_custom_expression_icon.png, in the Value field.

    Response: The Custom Expression dialog is opened.

  5. Specify the custom expression of your choice. For example, use "[Axis.Color]=true" to color all rows with the boolean value "true" with a specified color.

    Comment: Axis.Color represents the column you have selected to color by. In table visualizations you will also have access to the columns themselves and you can make direct column comparisons, e.g., [Col1]>[Col2], in the expression.

    Note: The output from the custom expression must be a boolean value.

  6. Click OK to close the dialog.

  7. Select a Color to represent the rule.

  8. Click OK.

    Response: The rule is added to the color scheme.

The custom expression can specify a certain value at which the exception rule should take over.

  1. Go to the Colors page of the Visualization Properties dialog.

  2. Click on the Add Rule... button to the right of the color scheme.

    Response: The Add Rule dialog is opened.

  3. From the Rule type drop-down list, select the rule type you want to use.

    Comment: For example, the rule type could be "Greater than or equal to" a value defined by the custom expression. There are a number of different rule types to choose from.

  4. In the Value field, click on the icon, color_value_menu_icon.png, to open the menu.

  5. Select Custom Expression.

    Response: The Custom Expression dialog is opened.

  6. Specify the custom expression of your choice.

    Comment: Axis.Color represents the column you have selected to color by. For example, if the rule type is "Greater than or equal to", then the expression "Avg([Axis.Color])+2*StdDev([Axis.Color])" would color all rows where the value of the selected color column is greater than or equal to the average value plus two standard deviations with the rule color.

    Note: The output from the custom expression must be an aggregated value.

  7. Click OK to close the dialog.

  8. Select a Color to represent the rule.

  9. Click OK.

    Response: The rule is added to the color scheme.

Note: When you are setting up a custom expression with a string comparison included, you need to put quotation marks around the string (for example, [Axis.Color]="Bananas"). If you define a rule containing a string comparison, however, you should not use quotation marks.

See also:

Color Rules

Custom Expressions Introduction