Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 9 Extending Report Table Attributes : Task B1: Add the Source for a Derived Value

Task B1: Add the Source for a Derived Value
You must provide a source to obtain a value for each derived report field. The value can be derived from a function, a rule, or another report field. Each derived field must have this source information individually designated. In the example report MONTHLY_EXPENSE, the report field DATE is derived from the $TRXDATE tool. Refer to TIBCO Object Service Broker Shareable Tools for more information on this tool.
Function Segment

 
LITERAL/DERIVED Field Definition
FUNCTION: Total: _ Count: _ Average: _ Max: _ Min: _ Std Dev: _ Variance: _
OF Field:
BY Field:
WHERE :
 
OR Source rule/field/text: $TRXDATE

 
Derived Fields
Note the following points about a derived field:
If the value for the field is derived from a report function, select the function and type your specifications into the appropriate argument fields. You can select only one function per derived field.
Deriving fields from a report function is available only through the Report Definer. If you want to perform this functionality on a report you created with the Report Generator, you must first save the report in the Report Definer and then access the LITERAL/DERIVED Field Definitions segment of the Expand screen in the Report Table Painter.
Using Report Functions
To use report functions, complete the following tasks:
1.
Type an alphanumeric character (0-9, A-Z) in the field to the right of the function.
2.
To specify more than one report field for the OF Field or BY Field arguments, type in the fields separated by blanks.
3.
To specify selection criteria for the occurrences to be used by the report function, type in this criteria to the WHERE argument.
Arguments and Selection
The arguments and selection are used as follows:
The field on which the report function is to be performed. For the report function COUNT, more than one field can be specified.
The field or fields by which the function is calculated. BY field values partition the report table occurrences into sets. The report function value stored on any given occurrence is the one that was calculated using the set of occurrences that contains the current value of the BY fields.
The selection criteria used to further limit the set of occurrences available for the report function. The selection criteria entered on the Control Field screen are not applied to the occurrences used by the report function.
Valid Report Functions
The report functions are used as follows:
Returns the total of the values of the OF Field for the selected occurrences.
Returns the count of the unique OF Field values for the selected occurrences. If no field name is specified in the OF Field, Count returns the total number of occurrences based on the WHERE clause.
Returns the mean value of the OF Field for the selected occurrences.
Returns the maximum value of the OF Field for the selected occurrences.
Returns the minimum value of the OF Field for the selected occurrences.
Returns the standard deviation of the values of the OF Field for the selected occurrences. Standard deviation is the square root of the variance.
Returns the variance of the values of the OF Field for the selected occurrences. The formula used to derive the variance is as follows:
xi is an individual value of report field x
n is the count of selected values of x
x is the mean of the selected values of x
Using Special Functions
Two additional functions are provided in the special functions segment:
You enter these functions in the Source rule/field/text field. This field also displays the actual text associated with a literal field. To display this information, position your cursor on the literal text and press PF15. The information that appears cannot be modified.
Special Function Segment

 
OR Source rule/field/text: $REPORT_NAME

 
Deriving a Value Based on a Field or Rule
To derive a value based on a field or a rule, type the name of the field or the name of the rule in the Source rule/field/text field, for example, ­$TRXDATE.
Report fields that are referenced in a rule must be passed in as arguments to the rule in the Source rule/field/text field of the screen.
Example
A report SHOWITEMS contains a report table RPTITEMS that includes four fields: ITEM#, PRICE, TAX, and TOTAL. Sample output for the report is shown here:

Items and Total Costs
 
Item# Price Tax Rate Total
 
1 $10.00 0.1500 $11.50
2 $19.95 0.0700 $21.34
3 $24.49 0.2300 $30.12

 
In the report table RPTITEMS, the value of the TOTAL field is derived from the TOTCOST rule that takes the PRICE and TAX fields as arguments, as in the following:

 
COMMAND ==> Scroll:
-----------------------------------------------------------------------------
Literal: N Definition for FIELD: TOTAL
 
. . .
 
OR Source rule/field/text: TOTCOST(PRICE, TAX)

 
When the rule executes, it takes the values passed from the PRICE and TAX fields, calculates a new value, and returns it to the TOTAL field.
An example of the rule is shown here:

 
RULE EDITOR ===> SCROLL: P
TOTCOST(ARG1, ARG2);
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ RETURN(ARG1 + ARG1 * ARG2); | 1
_ ---------------------------------------------------------------------------

 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved