0
Working with Calculations and Totals
0

About Calculations, Totals, and Sorting

Once you add fields and filters to your report, you might want to calculate and manipulate the data on your report. There are the following three primary methods:

  • Changing the way totals are displayed. For example, display totals as Averages.
  • Adding new fields that originate from existing fields. For example, based on the field Revenue, you create % of Revenue.
  • Creating new numbers on the fly.

Displaying Grand Totals

By default, Grand Totals don't display when you view a report in table format (grid of rows and columns). Also, Totals never display when you view a report in chart format.

To show or hide Grand Totals, do the following:

  1. Click the More actions and options button and select Report Options... from the menu to open the Report Options dialog box.
  2. Select or deselect the appropriate checkboxes in the Totals section.
  3. Click the OK button to save your specifications.

To hide Grand Totals while viewing a report in table report, click the Grand Total cell on the report, and select Hide Grand Total from the menu. Note that this method does not allow you to show Grand Totals again, once it is hidden.

Displaying Totals as Averages, Max, Min, etc

Grand totals and subtotals summarize detail row or column values. You can choose to summarize the data in the following ways:

  • Aggregate - Default. Displayed as Total in table report. Summarizes based on the aggregator of the underlying measure.
  • Sum - Useful for keeping duplicates in distinct count measures.
  • Average - See also: More about Averages.
  • Max
  • Min

To display these, click the number field (such as "Sales Revenue") in the report and select Show Average, Max, Min, etc from the menu.

More about Averages

In most cases, it looks like Pentaho totals are simply summing the individual values that are visible in the report. However, it is smarter than that and this is especially beneficial for fields that lend themselves to averages, such as ratios. This is best illustrated in an example.

Assume we want to view the Win Rate of a sales team for the entire country, as well as for each region. The user brings the field "Win Rate", "Region" and a couple of other fields into the report, and Analyzer automatically shows the correct Win Rate across the regions (1.3%). We don't have to, and shouldn't, use the Average option for Grand Totals in this case.

image 1

The average option is appropriate for the first two number fields, and the user may use the Averages option for these two fields.

image 2

If the user would still go ahead and choose to display "Win rate" as an average she would see 23.3% which is not a meaningful number.

image 3

Displaying Totals that Also Include Filtered Out Values

By default, Totals sum only the values that are visible on the report. If values are filtered out they will not be part of the total. This is illustrated below.

image 4

If we filter out a Product Line, the totals row will change accordingly:

image 5

However, you may also want see a total that includes the values that are filtered out and Pentaho offers this option. Continuing on the example above we would get:

image 6

Note that the new total still restricts data to 2006 Q4. Any filters applied to fields placed on the opposite axis would still apply, as would filters that apply on fields to the left of the total.

To display a total that also includes values that are filtered out, click the Grand Total cell on the report, and select Display Total that Includes Filtered Out Values from the menu.

Alternatively, click More Actions and select Report Options from the menu. Then check the Also Display Totals that Include Filtered Out Values checkbox.

Displaying % of, Rank, Running Sum, etc

To display % or, Rank, Running Sum, etc, click a field on the report and select % of, Rank, Running Sum, etc from the menu. Then, select the appropriate option.

This will create a new field in your report that behaves similar to any other fields. The differences are:

  • You may not filter based on this field
  • You may not create another field (% or, Rank, Running Sum, etc) based on this field

See below for further help on each option.

% of

When displaying values as percentages (%) you have four options:

  • Grand Total Column is 100%
  • Grand Total Row is 100%
  • Grand Total in lower right corner is 100%
  • Each <field> adds to 100%

Below follows an example that illustrates each option.

Grand Total Column is 100%

image 7

Grand Total Row is 100%

image 8

Grand Total in lower right corner is 100%

image 9

Each <field> adds to 100%

This option is only available when you have multiple text fields on the report

image 10

Rank

When ranking values (such as Product Lines) by a number field (such as Sales Revenue), you have three options

  • Rank across Rows
  • Rank across Columns
  • Rank Within <field>

Below follows an example that illustrates each option.

Rank across Rows

image 11

Rank across Columns

image 12

Rank Within <field>

This option is only available when you have multiple text fields on the report

image 13

Note that you are always ranking by the innermost row/column ('Product Line'). You may not rank by 'Region'.

Running Sum

The most common use of Running Sum, (a.k.a. Cumulative Sum) is to show how a number grows over time. For example, what was total sales revenue for this year, up and through January, February, March, etc.

When creating a Running Sum field you have three options:

  • Sum across all Rows
  • Sum across all Columns
  • Break By <field>

Below follows an example that illustrates each option.

Sum across all Rows

image 14

Sum across all Columns

image 15

Break By <field>

This option is only available when you have multiple text fields on the report

image 16

% of Running Sum

The % of Running Sum option combines the % of and the Running Sum functionality. You have three options:

  • Sum across all Rows
  • Sum across all Columns
  • Break By <field>

Below follows an example that illustrates each option.

Sum across all Rows

image 17

Sum across all Columns

image 18

Break By <field>

This option is only available when you have multiple text fields on the report

image 19

Sorting

By default, your report is sorted in alphanumeric order by text fields (such as 'Product Line').

To re-sort a row or column click the field on the report and select a Sort options from the menu.

The image below illustrates which fields can be re-sorted based on their placement on the report.

image 20

Creating New Measures

Pentaho allows you to create three types of new measures directly within a report:

  • % of, Rank, Running Sum, etc. (Described above)
  • Calculated Measures
  • Trend Measures

Creating Calculated Measures

  1. Right click on the column header for a measure in your report and select User Defined Measure &rarr Calculated Measure…
  2. In the New Calculated Measure dialog box, give your new measure a name.
  3. Determine the format and measure or decimal places and then select from your metric list to create a new measure using the operators that are available.

Tips on Creating Calculated Measures

  • Calculated measures are based on any valid MDX expression that evaluates to a calculated member
  • Advanced expressions will reference other dimensions via the dimension's MDX name. To find the MDX name, right click on any field and select "Tell me about..."
  • You can pin measures to specific members of a dimension.
    • Ex. ([Measures].[Unit Sales], [Product].[Food], [Gender].[M])
  • You can generate level based measures using Ancestor or Parent MDX functions
    • Ex. ([Measures].[Unit Sales], Ancestor([Product].CurrentMember, [Product].[Product Family]))
  • You can do if-else conditional logic using the IIf or Case MDX functions
    • Ex. IIf ([Product].CurrentMember Is [Product].[Food], [Unit Sales] * 1.1, [Unit Sales])
  • You can compare bookings for each sales rep to the best sales rep in his team
    • Ex. [Bookings]/([Bookings],Order(Descendants([Sales Rep].CurrentMember.Parent, [Sales Rep].[Sales Rep]), [Bookings], DESC).Item(0))
  • See here for a list of available MDX functions

Subtotal Calculation

    Checking the Subtotal Calculation checkbox will set the subtotals to be computed by computing the result of the formula with the base number's subtotals. Un-checking this checkbox will set the subtotals to be computed as a summary of the calculated number's different values. The two subtotal approaches are demonstrated in the following table:
    Regular Subtotals
      Column X     Column Y     Calculated Column X/Y  
      X1     Y1     X1/Y1  
      X2     Y2     X2/Y2  
      Subtotal(X1, X2)     Subtotal(Y1, Y2)     Subtotal(X1/Y1, X2/Y2)  
    Subtotals Using Formula
      Column X     Column Y     Calculated Column X/Y  
      X1     Y1     X1/Y1  
      X2     Y2     X2/Y2  
      Subtotal(X1, X2)     Subtotal(Y1, Y2)     Subtotal(X1, X2)/Subtotal(Y1, Y2)  
Related Topics