Oracle9i OLAP Services Developer's Guide to the Oracle OLAP API Release 1 (9.0.1) Part Number A88756-01 |
|
Performing Calculations, 2 of 7
Using the OLAP API you perform basic numeric operations using NumberSource
methods such as minus
. There are separate versions of each of these methods that you can use to specify a literal double
, float
, int
, or short
value. There is also a version of each of these method that takes a NumberSource
as an argument.
The OLAP API methods that you use to perform basic numeric operations include those outlined in the following table.
Assume, as shown below. that there is a NumberSource
named unit_Cost
that has outputs of productsDim
and timesDim
and a type of Integer.
Output2 |
Output1 |
Element |
---|---|---|
|
|
|
Boys |
1998 |
4000 |
Boys |
... |
... |
Boys |
31-DEC-01 |
10 |
... |
... |
... |
49780 |
1998 |
500 |
49780 |
... |
... |
49780 |
31-DEC-01 |
9 |
Now assume that you want to subtract 10% of the sales from each element to find the adjusted income for each product. To do this you use the following code.
NumberSource percentAdjustment = unit_Cost.minus(unit_Cost.times(.10));
The new NumberSource
, named percentAdjustment
, has the following structure and values.
Output2 |
Output1 |
Element |
---|---|---|
|
|
|
Boys |
1998 |
3600 |
Boys |
... |
... |
Boys |
31-DEC-01 |
9 |
... |
... |
... |
49780 |
1998 |
450 |
49780 |
... |
... |
49780 |
31-DEC-01 |
8 |
Assume that you have the NumberSource
named unitCost
described in the previous example and that you also have the NumberSource
named unitManufacturingCost
shown below.
Output |
Output |
Element |
---|---|---|
|
|
Integer |
Boys |
1998 |
600 |
Boys |
... |
... |
Boys |
31-DEC-01 |
3 |
... |
... |
... |
49780 |
1998 |
250 |
49780 |
... |
... |
49780 |
31-DEC-01 |
2 |
Now assume that you want to calculate the non-manufacturing for each product. To do this you need to subtract the manufacturing costs from the unit costs using the code shown below.
NumberSource nonManufacturingCost = unitCost.minus(unitManufacturingCost);
The new NumberSource
has the structure and values shown below.
Output |
Output |
Element |
---|---|---|
|
|
Integer |
Boys |
1998 |
3400 |
Boys |
... |
... |
Boys |
31-DEC-01 |
7 |
... |
... |
... |
49780 |
1998 |
250 |
49780 |
... |
... |
49780 |
31-DEC-01 |
7 |
For a more complete explanation of these methods, see Oracle OLAP API Reference.
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|