Oracle9i OLAP Services Developer's Guide to the Oracle OLAP API Release 1 (9.0.1) Part Number A88756-01 |
|
Performing Calculations, 5 of 7
The numerical aggregation methods provided by the OLAP API include the methods in the following table. You can also write your own aggregation functions as described in "Creating Your own Numerical Functions".
There are two different versions of each of the numerical aggregation methods. One version excludes all null values when making its calculations. The other version allows you to specify whether or not you want null values included in the calculation. Each version returns a new NumberSource
that, for each set of input values, has an element whose value is the sum of all of the elements in the original NumberSource
that have the same set of input values
Standard numerical methods like stdev()
work on each element in a NumberSource
. An aggregation method is a method like total()
that uses the values in a series of Source
elements to perform its calculations. When a NumberSource
does not have any inputs, this method creates a new NumberSource
with a single element whose value is the sum of the values of the elements in the original NumberSource
.
When a NumberSource
has inputs, each set of input values identifies a subset of elements (tuples) that are arranged by the outputs of the NumberSource
(if any). In this case, an aggregation method works on each set of uniquely positioned elements. In other words, when a NumberSource
has inputs, an aggregation method calculates the result of the function for each subset.
For more information on how OLAP API methods determine the position of an element and therefore how they determine what elements to use when calculating the values of aggregation methods, see "Finding the position of elements".
Assume that you have the Source
named unitsSoldByCountry
(shown below) whose elements are the total number of units for each product sold for each country.
Output |
Output |
Element |
---|---|---|
|
|
Integer |
395 |
Australia |
1300 |
395 |
United States |
800 |
... |
... |
|
49780 |
Australia |
10050 |
49780 |
United States |
50 |
49780 |
... |
|
Now assume that you want to total these values. Since both products
and countries
are outputs, when you issue the code shown below, the new NumberSource
calculates the total number of units sold for all products in all countries.
NumberSource totalUnitsSold = unitsSoldyByCountry.total();
The new NumberSource
called totalUnitsSold
has only a single element that is the total of the values of the elements of unitsSoldByCountry
.
Element |
---|
Integer |
11350 |
Assume that you have the Source
named unitsSoldByCountry
(shown below) whose elements are the total number of units for each product sold for each country.
Output |
Input |
Element |
---|---|---|
countries |
products |
Integer |
Australia |
395 |
1300 |
Australia |
49780 |
10050 |
... |
... |
... |
United States |
49780 |
50 |
United States |
395 |
800 |
... |
... |
|
Now assume that you total these values. Since product
is input, when you issue the code shown below, the new NumberSource
calculates the total number of units sold for all products in each countries;. It does not calculate the total for all products in all countries.
NumberSource totalUnitsSoldByCountry = unitsSoldByCountry.total();
The new NumberSource
called totalUnitsSoldByCountry
has the structure and values shown below.
Input |
Elements |
---|---|
countries |
Integer |
Australia |
11350 |
... |
... |
United States |
850 |
... |
... |
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|