| Oracle Discoverer Administration Edition Administration Guide Release 4.1 for Windows A86730-01 |
|
This chapter consists of the following sections:
Typical business calculations include values such as profit margins, average revenues per month, expected sales, and percent of profit by product type. You can represent these business calculations in Discoverer by creating Calculation Items. Once created, Calculation Items behave much like any other Item in a Folder and can be used in Conditions, Summaries, Lists of Values, Joins, and other Calculation Items.
You create Calculation Items using expressions that can contain:
There are three types of calculations:
Derived items and aggregate calculations appear with different symbols to differentiate them. Aggregate derived items appear with the same symbol as derived items. For more information about the Icons that appear in the work area, see Section 3.3, "The Work Area."
A derived item is a non-aggregate expression that appears and acts exactly like any other item in the folder. Derived items can be axis items or data points and can be used anywhere one would use an ordinary item. They are static, in that their value depends only on the value of the other items in the same row, and when computed will be the same regardless of what other items are selected in the user's query.
Examples of Derived Items:
Sal*12+NVL(Comm,0)
Initcap(Ename)
1
Sysdate-7
If the formula of a new item contains an aggregate or group function such as SUM, AVG, MAX, MIN, or COUNT, and the items it aggregates are in the current folder, the item is created as an aggregate calculation.
Examples of Aggregate Calculations:
SUM(Sal)*12
SUM(Comm)/SUM(Sal)
AVG(Monthly Sales)
Aggregate calculations are dynamic, in that their value depends on the other items selected in the Discoverer Plus worksheet in which they are used, because this affects the axis items that are grouped together and hence the number of rows that are aggregated. This is particularly important in the case of calculations that are ratios of two aggregates.
For example to calculate Margin, one would use the calculation SUM(Profit)/SUM(Sales) rather than Profit/Sales. Used in a query, the latter would result in SUM(Profit/Sales), which produces a different result from SUM(Profit)/SUM(Sales). Data points should always be summed before a ratio is computed.
Aggregate Calculations:
Aggregate calculations do not affect the row set of the folder. Their dynamic nature means that they only affect generated SQL when selected in Discoverer Plus.
An aggregate derived item is a calculation created in a complex folder that aggregates items in one or more of the source folders. Aggregate derived items behave in all respects like ordinary derived items, and are used where there is a requirement to nest aggregate functions.
Aggregate derived items always affect the row set of the folder, because they cause the whole folder to be aggregated by all the other axis items in the folder, even if the axis items are not used in a sheet.
Example of an Aggregate Derived Item:
The complex folder Monthly Sales Analysis contains a row for every store, for every month.
SUM(Video Analysis.Sales)
This item shows the total sales for a given store in a given month.
Average Monthly Sales per Store = AVG(Monthly Sales Per Store)
This item shows the average monthly sales and can be analyzed over region, quarter, year, etc., to compare trends. This sort of nested aggregate is only possible by creating the aggregate item in a new folder, because this folder now represents monthly sales, not the individual sales that were in the original complex folder.
Aggregate derived items cause the folder SQL to contain a GROUP BY and all end-user queries to return one row for each combination of all the other non-aggregated items, regardless of whether the calculation is used in the query. This reduces the number of rows returned by the folder, because they are aggregated at the level of the other items.
Calculation Items can be a critical part of an end user's report. As Discoverer Administrator, you should set up commonly used calculations as predefined Items in a Folder. This makes them available for inclusion in Discoverer Plus worksheets.
Creating Calculation Items provides the following benefits:
Analytic Functions behave like Aggregate Calculations except for the following:
For further information about Analytic Functions refer to the Discoverer 4i Plus User's Guide.
You can obtain more information about Calculations in Oracle Discoverer from the following sources:
This section describes how to create a new Calculation.
There are three ways of doing this:
The New Item dialog box (see Figure 12-2) enables you to create a new Calculation Item and add it to the selected Folder.
|
NOTE: If you didn't select a Folder in step 1, Discoverer Administration Edition displays the New Item dialog box (see Figure 12-1). Select the Folder that you want to contain your new Calculation using this dialog box (you can select any Folder from within any open Business Area). |
|
NOTE: Calculations follow the Oracle calculation standard syntax. For a full description of this syntax, see the Oracle SQL Language Reference Manual. |
However, the New Item dialog box has the following features to help you construct the Calculation without needing prior knowledge of the syntax:
If you select Items, the Show area displays a list of the Items in the selected Folder (if the selected Folder is a Complex Folder, the source Folders and their Items are also displayed here).
You can insert an Item in the list into your Calculation by double-clicking on it (you can also select the Item and click Paste).
If you select Functions, the Show area displays a list of the Functions (grouped by type) available for use in your Calculation.
If you have registered a custom PL/SQL function, it will appear in the Database group. For more information, see Section 12.6, "Registering Custom PL/SQL Functions."
You can insert a Function in the list into your Calculation by double-clicking on it (you can also select the Function and click Paste).
You can insert any of the operators (listed along the bottom of the Calculation area) into your Calculation by clicking on them.
You can resize the New Item dialog box to give you more room to type your Calculation.
For more information see the Oracle Discoverer Plus User Guide.
You can now use this new Item to create joins, conditions, and even new calculations.
Item properties are accessible through Item Properties dialog boxes. This section shows you how to enhance the user's view of the data by editing item properties. Figure 12-3 shows an example Item Properties dialog box.
This section describes how to edit an item's properties.
There are four ways to do this:
For more information on the fields on this dialog box, click Help.
The following steps show you how to set common properties for more than one item at a time:
There are three ways to do this:
All properties that are common to each of the selected folders are displayed. If the data for a field is not common to each of the selected folders, the field is blank.
For more information on the fields on this dialog box, click Help.
This section describes how to edit an existing Calculation.
There are three ways to do this:
The Edit Calculation dialog box works in the same way as the New Item dialog box (see Section 12.2, "Creating Calculations" for more information).
This section describes how to delete Calculation Items.
To select more than one Item at once, hold down Ctrl while you click on the Items.
There are three ways to do this:
This opens the Confirm Delete dialog box.
In addition to the PL/SQL functions provided by Oracle, you can create custom PL/SQL functions to meet your users' requirements. These can be used to provide predefined functions for complicated calculations. User-defined PL/SQL functions become part of the total set of PL/SQL functions available to all database processes.
To be able to access custom PL/SQL functions using Discoverer, you must have first registered them in the EUL. Once registered, user-defined PL/SQL functions appear in the list of database functions in the Edit Calculation dialog box and can be used in the same way as the Oracle-supplied functions.
In Discoverer Plus, folders that contain derived items using PL/SQL functions will not be visible to users who do not have EXECUTE privileges on those functions. To make those functions accessible, ensure that the user has the associated EXECUTE privilege in the database.
There are two methods for registering functions:
Which you choose depends on the version of the Oracle database you're using:
This section describes how to manually register a PL/SQL function for use in Discoverer.
This opens the PL/SQL Functions dialog box on the Functions page (see Figure 12-5).
This checks the validity and accuracy of the information you have entered.
The custom PL/SQL function is now registered for use in Discoverer.
This section describes how to register PL/SQL functions automatically:
This opens the PL/SQL Functions dialog box on the Functions page (Figure 12-5).
This opens the Import PL/SQL Functions dialog box (see Figure 12-7), which enables you to select the PL/SQL functions that you want to register.
All of the pertinent information about the selected functions is imported, and you do not have to manually enter information or validate it.
|
|
![]() Copyright © 2000 Oracle Corporation. All Rights Reserved. |
|