Learning
Community
Open Exchange
Global Masters
InterSystems IRIS Data Platform 2019.4 / Analytics / Using the Analyzer / Customizing Pivot Tables
Previous section   Next section

Customizing Pivot Tables

This chapter describes how to further customize pivot tables. It discusses the following topics:
Also see “Accessing the Samples Shown in This Book,” in the first chapter.

Specifying Pivot Options

The Pivot Options dialog box provides many ways to customize the pivot table. To access this dialog box, click the Pivot Options button images/d2anly_button_pivot_options.png. The Analyzer displays the following:
images/d2anly_pivot_options.png
Here you can do the following:
  • Format the pivot table with zebra stripes. If you select Zebra Striping, the table is formatted with rows in alternating colors as follows:
    images/d2anly_pivot_zebra.png
  • Remove the captions for the rows. To do so, clear Row Caption.
  • Specify which listing to use for this pivot table. To do so, select a listing from the Listing drop-down menu.
  • Specify the maximum number of records to include in listings for this pivot table. To do so, specify a value for Maximum Listing Rows. The default is 1000.
  • Apply custom colors and font styles. To do so, use the drop-downs in Row Options, Column Options, or Cell Options. For example:
    images/d2anly_pivot_options_css_specified.png
    This style definition specifies that the font is in 12 pt, blue Verdana on a pale green background. The text is also bold and center-aligned.
    If you specify a custom color for the cell background in Cell Options, the system ignores the Zebra Striping option.
  • Use the Span Labels options to control whether labels are spanned.
    When you display the table in a nested format, the labels are spanned by default. For example:
    images/d2anly_rowopt_nested_items.png
    You can instead repeat the relevant labels, as follows:
    images/d2anly_row_label_unspanned.png
  • Use the Show Empty options to control whether empty rows and columns are displayed.
  • Control the size of the data cells. To do so, type the width in pixels into Width and the height in pixels into Height.
As you make changes, the Preview area is updated to demonstrate the changes. For example:
images/d2anly_color_preview_with_font_size.png
If you have enabled the %SQLRESTRICT dimension for a cube, you will see the SQL Restriction field. If you wish to apply an SQL Restriction for the current pivot table, enter a valid SQL SELECT statement or WHERE clause. For more information, see the %FILTER Clause section of the InterSystems MDX Reference.

Customizing Pivot Table Items

The Analyzer displays Advanced Options button images/d2anly_button_advanced_options.png in the Rows, Columns, and Measures boxes, next to each item in those boxes. The same button is also available for the Rows and Columns boxes.
For example:
images/d2anly_button_advanced_options_where.png
If you click any of these buttons, you see the following dialog box or a variation of it (the details are different for measures). The following figure shows only the top part of the dialog box:
images/d2anly_analyzer_axis_options.png
The following sections describe changes you can make.
You can specify formatting in multiple places. If you specify different formatting, the following rules control which formatting options are used:
  • Wherever possible, all the formatting is used. For example, if you specify the typeface to use for rows and the color to use for columns, both of those format options are applied.
  • Formatting specified for a measure in a pivot table takes precedence over formatting specified elsewhere.
  • Formatting specified for columns takes precedence over formatting specified for rows or the entire pivot table.
  • Formatting specified for rows takes precedence over formatting specified for the entire pivot table.
  • Formatting specified in the pivot table takes precedence over formatting specified in a measure definition (other model elements do not have format options).

Displaying a Constant Row or Column

You can display a constant value rather than the selected item. To do so:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item.
  2. Click Value.
  3. Type a value into Value. For example:
    images/d2anly_analyzer_axis_options_constant_value.png
  4. Click OK.
You might also want to specify a different caption; see “Specifying New Captions,” later in this chapter.

Specifying a Spacer Row or Column

You can display a spacer row or column rather than the selected item or items. To do so:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item.
  2. Click Space.
  3. Click OK.
The following shows an example:
images/d2anly_spacer_row_demo.png
For this pivot table, the Rows definition is as follows:
images/d2anly_spacer_row_howto.png

Displaying an Different Set for Rows or Columns

You can display an alternative set of elements rather than the selected item or items. To do so:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item.
  2. Click Advanced.
  3. Type an MDX set expression into MDX Expression.
    For information, see Using InterSystems MDX.
  4. Click OK.

Specifying New Captions

To specify new captions:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item or in the header of the Rows or Columns box, as appropriate.
  2. Type a value into Caption.
    To include the original name in the caption, use an asterisk (*) at the appropriate position.
  3. Click OK.
For example:
images/d2anly_pivot_new_captions.png
In this case, Caption is Group: *

Specifying a Format String

A format string controls how numbers are displayed and can also specify colors to use. To specify the format string for an item:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item or in the header of the Rows or Columns box, as appropriate.
  2. Click the Find button images/d2anly_button_search.png next to Format.
    The system displays a dialog box that includes the following fields:
    images/d2anly_format_string_ui.png
    Here:
    • Positive piece specifies the format to use for positive values.
    • Negative piece specifies the format to use for negative values.
    • Zero piece specifies the format to use for zero.
    • Missing piece specifies the format to use for missing values.
    In each of these, Format string specifies the numeric format, and Color specifies the color.
  3. Specify values as needed (see the details after these steps).
  4. Click OK.

Format String Field

The Format string field is a string that includes one of the following base units:
Base Unit Meaning Example
# Display the value without the thousands separator. Do not include any decimal places. 12345
#,# Display the value with the thousands separator. Do not include any decimal places. This is the default display format for positive numbers. 12,345
#.## Display the value without the thousands separator. Include two decimal places (or one decimal place for each pound sign after the period). Specify as many pound signs after the period as you need. 12345.67
#,#.## Display the value with the thousands separator. Include two decimal places (or one decimal place for each pound sign after the period). Specify as many pound signs after the period as you need. 12,345.67
You can include additional characters before or after the base unit.
  • If you include a percent sign (%), the system displays the value as a percentage. That is, it multiplies the value by 100 and it displays the percent sign (%) in the position you specify.
  • Any other characters are displayed as given, in the position you specify.
The following table shows some examples:
Example formatString Logical Value Display Value
formatString="#,#;(#,#);"
Note that this corresponds to the default way in which numbers are displayed.
6608.9431 6,609
–1,234 (1,234)
formatString="#,#.###;" 6608.9431 6,608.943
formatString="#%;" 6 600%
formatString="$#,#;($#,#);" 2195765 $2,195,765
–3407228 ($3,407,228)

Color Piece

For the Color field, specify either of the following:
  • A CSS color name such as MediumBlue or SeaGreen. You can find these at https://www.w3.org/TR/css3-color/ and other locations on the Internet.
  • A hex color code such as #FF0000 (which is red).
  • An RGB value such as rgb(255,0,0) (which is red).

Specifying Cell and Header Styles

To specify the cell and header styles for an item:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the item or in the header of the Rows or Columns box, as appropriate.
  2. Select values in the Cell Style and Header Style groups. These enable you to specify the style of the cells and the headers, respectively:
    images/d2anly_css_init.png
    To use these options, click each drop-down and select a value. For example:
    images/d2anly_css_specified.png
    This style definition specifies that the header is in 12 pt, blue Verdana on a pale green background. The header is also bold and center-aligned.
  3. Click OK.

Sorting and Filtering Members

You can filter and sort the members of a level or named set in various ways. To do so:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to a level or named set or in the header of the Rows or Columns box, as appropriate.
  2. Specify the following options as needed:
    • Filter members — Select this to filter the members by a measure value. Then select a measure and a comparison operator and type a value.
    • Sort members — Select this to sort the members. Then select the measure by which to sort them. Click Ascending or Descending to control how the members are sorted.
    • Return the first n members — Select this to select a subset from the beginning of the set. Then type an integer into Count.
      When you use this option, the system first uses any settings you specified for the Filter members and Sort members options.
  3. Click OK.

Specifying Alternative Aggregation Methods for a Measure

For any cell in a pivot table, each measure is aggregated from the lowest-level data. Aggregation methods include sum, average, maximum value, and others. By default, the system uses the aggregation method specified in the measure definition. You can specify an alternative method.
Similarly, if you add a summary row or column, you specify how to aggregate the displayed values into a single number for that summary row or column. You can specify an alternative method for this as well.
To specify alternative aggregation methods for a measure:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png next to the measure.
  2. Specify either or both of the following options:
    • Measure Aggregate specifies how this measure is aggregated from a set of values in your data.
      The choices are SUM, AVG, MIN, MAX, and COUNT.
    • Total Override specifies how the displayed measure values are aggregated for any summary rows or columns.
      The choices are Sum, Count, Min, Max, Average, % of Total, and None.
  3. Click OK.
See also “Adding a Summary Row or Column,” earlier in this book.

Customizing Double-Click Drilldown

By default, when you double-click a row in a pivot table, the system drills down to the next lowest level in the hierarchy, if any (see “Drilldown via Double-Click,” later in this book). You can customize this behavior. To do so:
  1. Click the Advanced Options button images/d2anly_button_advanced_options.png in the header of the Rows box.
  2. Expand the Drilldown Options group if that is collapsed.
  3. For Drilldown Expression, specify one or more MDX set expressions, one per line. For example:
    colord.h1.[favorite color].members
    gend.h1.gender.members
    
    To specify MDX set expressions, you can do either of the following:
    • Type the expression directly into Drilldown Expression.
    • Use the Expression Builder. To access this tool, click the plus sign images/d2anly_button_expressionbuilder.png next to Drilldown Expression. The left area lists the contents of the cube, including all measures and levels. The right area displays the expression that you are creating. To add an item to the expression, drag and drop it from the left area to the expression. The item is added to the end of the expression, and you might need to move it to a different part of the expression.
    Typically you use set expressions of the form [dimension].[hierarchy].[level].MEMBERS, where dimension is the logical name of a dimension, hierarchy is the logical name of a hierarchy, and level is the logical name of a level. This expression represents the members of the given level.
    If these identifiers do not include spaces, you can omit the square brackets. Also, the expression is not case-sensitive.
    The first set expression controls what happens when the user double-clicks the first time. Specifically, when the user double-clicks the first time, the system creates a new query that uses this set expression for rows and that is filtered to the given context.
    Similarly, the second expression controls what happens when the user double-clicks the second time, and so on.
    The Drilldown Expression option overrides any other drilldown behavior in this pivot table. That is, if a level is in a hierarchy, the hierarchy drilldown behavior does not occur for this pivot table.
  4. Click OK.
For an example, see “Custom Double-Click Drilldown,” later in this book.
Note:
The same option is available in the Advanced Options button images/d2anly_button_advanced_options.png in the header of the Columns box. This option is ignored by default but is used if you pivot the table (via the Transpose button images/d2anly_button_pivot.png) and then perform double-click drilldown.

Applying Conditional Formatting

You can apply conditional formatting, which can add color, text, or graphics to pivot table cells. To do so, you create rules that examine the values in the cells. This conditional formatting overrides any customization you added to the pivot table.
To do so, click the Conditional Formatting button images/d2anly_button_conditional_formatting.png in the toolbar. The system displays a dialog box like the following (in this example, one rule has been specified):
images/d2anly_cond_formatting.png
Here, you can do the following:
  • Clear all conditional formatting. To do so, click Clear rules.
  • Apply an overall color, based on values in the cells. To do so, click a button in the section Color all cells proportionally according to value. See “Applying an Overall Color.”
  • Define a custom gradient for use with the option Color all cells proportionally according to value. To define a custom gradient, use the two buttons displayed below My Colors. Click the first one and select a color to use at the bottom of the range. Click the second one and select a color to use at the top of the range. When you are done, the dialog box displays your gradient next to the predefined gradients. For example:
    images/d2anly_cond_formatting_gradient_custom.png
  • Create formatting rules. See “Adding a Rule.”
  • Change the order of the rules. To do so, click the up or down arrows in the row for a rule.
  • Delete a rule. To do so, click the X button in the row for that rule.
  • Reconfigure a rule. To do so, click the Reconfigure button images/d2anly_button_reconfigure.png in the row for that rule.
  • Apply the existing rules while leaving this dialog box open. To do so, click Apply.
  • Apply the existing rules and exit this dialog box. To do so, click OK.
  • Close this dialog box without making changes. To do so, click Cancel.
Rules are applied in the same order that they are listed here. If a later rule contains formatting information that is inconsistent with an earlier rule, the system uses the formatting specified in the later rule.

Applying an Overall Color

If you click a button in the section Color all cells proportionally according to value, the cells are colored according to their values. This works as follows: Each button displays a gradient of colors. To assign a color to a cell, the system examines the range of values of the cells. If a value is at the bottom of this range, the system uses the color that is shown at the top of the gradient button (a dark blue in the following example). If a value is at the top of this range, the system uses the color that is shown at the bottom of the gradient button (a light blue in the following example). For other values, the system uses an intermediate color. The following shows an example:
images/d2anly_cond_formatting_gradient_example.png

Adding a Rule

To add a rule, click the plus sign button. The system displays a dialog box where you can specify the rule details (in this example, one rule has been specified):
images/d2anly_cond_formatting_rule_editor.png
Here you can do the following:
  • Specify the numeric comparison for the rule to use. A rule compares the value in each cell (or in specific cells) to a constant, using an operator. For example:
    cell_value > 50
    
    For each cell where this rule is true, the rule is applied. All the display details of the rule are applied to that cell.
    To specify the numeric comparison, do the following:
    1. Select an operator from the first drop-down menu.
    2. Type a numeric constant into the field to the right of that.
  • Optionally specify which row, which column, or both the rule applies to. To do so, type a number into Row #, Col #, or both.
  • Optionally specify the text color to use when the rule is true. To do so, click a button in the Color section. If you select the left-most button, the system uses the default color.
  • Optionally specify the background color to use when the rule is true. To do so, click a button in the Background Color section. If you select the left-most button, the system uses the default color.
  • Optionally specify replacement text to display when the rule is true, instead of the actual cell value. To do so, type text into Replace cell contents with.
  • Optionally specify an icon to display when the rule is true, instead of the actual cell value. To do so, click a button in Display icon in cell. This area lists the system icons, followed by any custom icons defined by the implementers. (For information on adding icons that can be used here, see “Creating Icons” in Implementing InterSystems Business Intelligence.)
    If you select the left-most button, the system does not display an icon.
    To display multiple icons, click a number from the Number of icons to display list.
The bottom of the dialog box shows a preview of the formatting.

Specifying the Print Settings

To specify the print options for a given pivot table:
  1. Display that pivot table in the Analyzer.
  2. Click the Print Options button images/d2anly_button_print_options.png.
  3. Click Page Setup.
  4. Specify options as described in “Customizing Print Settings for a Widget” in Creating Dashboards.
  5. Click OK.
  6. Save the pivot table.
For comments on printing, see “Printing Pivot Tables,” later in this book.
Note that when you create dashboards, you can specify print settings in the dashboards as well. See “Customizing Print Settings for a Widget” in Creating Dashboards.

Specifying the MDX Query Manually

Sometimes it is useful to see and then modify the MDX query that the system generates for a pivot table. To do so:
  1. Click the Query Text button images/d2anly_button_query_text.png.
    The system then displays a dialog box that displays the query used by this pivot table.
  2. If you want to use a different query, click Manual Mode.
  3. Edit the query. See the following subsection for an example.
    If you had displayed a detail listing, the bottom area of this dialog box also displays the listing query that the system used:
    images/d2anly_manual_listing.png
  4. Click OK.
When the Analyzer displays a pivot table that is defined by a manually edited or manually entered MDX query, the Query Text button changes to the following: images/d2anly_button_query_manual.png. Also, the Rows, Columns, and Measures boxes are grayed out. You cannot use locally defined calculated members unless you also add the appropriate WITH clause to your query. You can, however, drag items to the Filters box; the system applies these filters but does not modify the manual query text. That is, the base query and its filters are stored separately within the pivot table definition.
Tip:
You can also use the Query Text option to copy and paste the query (for example, to use in the MDX shell).

Modifying Details of the 80/20 Suppression Option

For example, if you had used the 80/20 suppression option, the MDX query might look like this (with harmless line breaks added):
SELECT 
NON EMPTY {[Measures].[Amount Sold],[Measures].[Units Sold],[Measures].[%COUNT]} 
ON 0,
NON EMPTY 
{TOPPERCENT([Product].[P1].[Product Name].Members,80),
%LABEL(SUM(BOTTOMPERCENT([Product].[P1].[Product Name].Members,20)),"Other",,,,"font-style:italic;")} 
ON 1 
FROM [HoleFoods]
For the TOPPERCENT and BOTTOMPERCENT functions:
  1. The first argument specifies the set of members to use.
  2. The second argument specifies the percentage.
  3. The third argument (omitted in the preceding example) specifies the measure to use for ranking the members.
To change the percentages, change the second arguments for TOPPERCENT and BOTTOMPERCENT. For example:
SELECT 
NON EMPTY {[Measures].[Amount Sold],[Measures].[Units Sold],[Measures].[%COUNT]} ON 0,
NON EMPTY 
{TOPPERCENT([Product].[P1].[Product Name].Members,90),
%LABEL(SUM(BOTTOMPERCENT([Product].[P1].[Product Name].Members,10)),"Other",,,,"font-style:italic;")}
ON 1 
FROM [HoleFoods]
Previous section   Next section