IBM Support

Median values calculated appear to be too small

Troubleshooting


Problem

When median values are calculated, either through the use of the median() function, or by setting an aggregation property for a query item to median, the resulting values appear to be lower than they should be.

Cause

The value being calculated is the median of the individual rows coming from the database without aggregation.

Resolving The Problem

The media of a list of values is the value where half the values in the list are lower than it, and the other half are higher than it.

If the Auto Group and Summarize property of a query is set to True (the default value) then measures are aggregated to the lowest level of detail, so each detail row seen in the report can be an aggregation of any number of rows returned from the database.

Both the median function, and the median aggregation property will calculate the median of the individual values of it's operand unless aggregation is included in the expression.

For example, see the attached report and report output. Both lists in the report show the same data, but the first list has had its Auto Group and Summarize property set to False so the individual rows returned by the query can be seen. Notice that for Web based orders in 2010, the quantity of items ordered range from 1,471 to 142. The median of this list is correctly calculated as 583. Overall the media of all rows returned by the query is 402. These calculations are done using the median() function in the query item expression.

In the second list the data is grouped and summarized, and the medians and totals are performed using the Aggregation Function and Rollup Aggregation Function query item properties. The [Median for year] item has a Rollup Aggregation Function of Calculated, so the result in the Summary row is the median of all rows returned by the query. If that property was changed to Median, the value would change to 470, the median of the two detail values (583 and 356). Likewise the [Total for year] item has it's Rollup Aggregation Function set to Median, so the value calculated is the median of the two annual totals. If a median of annual totals needs to be calculated in a detail row, the totaling aggregation must be part of the expression. This is done in the second list by the [median of annual totals] item which has an expression of:


median(total([Total for year] for [Current year]) for report)

Using these examples you can control what list of values you take the median of.

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSTSF6","label":"IBM Cognos Analytics"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
17 November 2022

UID

swg21458868