Skip to main content
Pentaho Documentation

Apply Conditional Formatting to Measures

Conditional formatting in the Analyzer data grid means that cells will be physically affected by the data they contain. The most common form of conditional formatting is stoplight reporting, where cell backgrounds are colored red, green, or yellow depending on user-defined thresholds. Analyzer offers some simple pre-defined methods of conditionally formatting numeric data. Follow the directions below to implement conditional cell formatting.

  1. Right-click a measure in the grid, then select Conditional Formatting from the context menu. A sub-menu with conditional formatting types will appear.
  2. Select your preferred number format from the list.

The analyzer report will refresh and apply the formatting choice you specified.

Conditional Formatting Types

Indicator Type Description
Color scale The background cell color will be shaded according to the value of the cell relative to the highest and lowest recorded values in that measure. There are several color progressions to choose from.
Data bar The cell background is partially filled with a solid color proportional to the scale of the cell's value relative to the highest and lowest recorded values in that measure.
Trend arrow An upward or downward arrow is displayed to the right of the cell value depending on whether it contains a positive or negative value.

Advanced Conditional Formatting with MDX Expressions

If the premade conditional formatting options in Analyzer are not precise enough for your needs, you can apply custom formatting to a measure by using an MDX expression, as explained below.

  1. Right-click a measure in the grid, then select Column Name and Format... from the context menu. The Edit Column dialogue will appear.
  2. Select Expression from the Format drop-down list. A default MDX expression that prints green or red arrows in cells if their values are greater than or less than zero, respectively, will appear in the MDX Format Expression field:
    When [Measures].CurrentMember > 0
    Then '|#,##0|arrow=up'
    When [Measures].CurrentMember < 0
    Then '|#,##0|arrow=down'
    Else '|#,##0'
  3. Modify the expression to suit your needs. Consult Conditional Formatting Expressions for more information on conditional formatting syntax and options.
    Note: If the MDX expression is invalid, an invalid report definition error will appear at the top of the dialogue.
  4. Click OK to commit the change.

The analyzer report will refresh and apply the formatting choices you specified.

Conditional Formatting Expressions

Valid MDX format strings contain properties that apply special rendering for the HTML pivot tables. A format string follows this syntax:

| # , # # # | style = red

The leading | (pipe) tells Analyzer that this format string contains properties. The #,### is the measure's value format, which in this example is one number separated from three further places or decimal places by a comma (for instance: 3,667). style=red is a key/value pair; all possible keys and values are explained in the table below.

The following properties are supported by Analyzer:
Indicator Type Description Values
style Changes the cell background color. red, yellow, green
arrow Shows a trend arrow that points up or down. A value of none will not render the arrow; this is useful in situations in which you only want to show one directional arrow instead of two. up, down, none
link Creates an HTML link which will open in a new window when clicked in Analyzer. Any browser-renderable URL

Must be a fully-qualified URL

URL must be enclosed in quotes
image Renders a custom image that you specify. This image file must be stored in the /pentaho-solutions/system/analyzer/resource/image/report/ directory. An image file name, with extension