Showing posts with label Summary Columns. Show all posts
Showing posts with label Summary Columns. Show all posts

Summary Column properties

About summary column
A summary column performs a computation on another column's data.  Using the Report Wizard or Data Wizard, you can create the following summaries:  sum, average, count, minimum, maximum, % total.  You can also create a summary column manually in the Data Model view, and use the Property Palette to create the following additional summaries:  first, last, standard deviation, variance.

Break Order
Description The Break Order property is the order in which to display the column's values.  This property applies only to columns that identify distinct values of user-created groups (i.e., break groups).  The order of column values in a default group is determined by the ORDER BY clause of the query for SQL queries and by the sort column for Express queries.  For column values in user-created groups, however, you must use Break Order to specify how to order the break column's values.
Values
None
Ascending
Descending
Applies to columns
Required/Optional Required, if Set Break Order is set to ‘Yes’.
Default Ascending for database and sort columns. None for database columns representing dimensions in Oracle Express queries with break groups.


Function
Description The Function property is the computation to be performed on the values of the column specified in Source.  To create running summaries, you place the column in the appropriate group and use Function in conjunction with Reset At.
Values
Average        Calculates the average of the column's values within the reset group.

Count            Counts the number of records within the reset group.

First              Prints the column's first value fetched for the reset group.

Last              Prints the column's last value fetched for the reset group.

Maximum       Calculates the column's highest value within the reset group.

Minimum       Calculates the column's lowest value within the reset group.

% of Total     Calculates the column's percent of the total within the reset group.

Std. Deviation Calculates the column's positive square root of the variance for the reset group.

Sum              Calculates the total of the column's values within the reset group.
Variance        Sums the squares of each column value's distance from the mean
Value of the reset group and divides the total by the number of values minus 1.
Applies to summary columns
Required/Optional required, if column is a summary column.
Default blank


Reset At
Description  The Reset At property is the group at which the summary column value resets to zero (if Function is Count), null (if Function is not Count), or Value If Null (if the column has one).  Reset At has a list of values containing valid reset groups.  Reset At determines if the summary is a running summary or a periodic (e.g., group-level) summary.
Value
Page             Is used for page-level summaries.  The summary is reset between pages.

Report           Is used for summaries that apply to the entire report, such as grand totals.  The summary is reset after the report (i.e., it is never reset).

<Names>       Is a valid group name.  The summary is reset after each record of the group.

Applies to     summary columns
Required/Optional required, for columns of Type Summary.
Usage Notes
  • The reset group of a summary column may be its group or any group above its group, including Report and Page.
  • To ensure that page summaries behave in a predictable way, make sure each record fits on a single page, or if that is not feasible, force each new record to print on a new page.


Example
Suppose that you want to create a group report like the one below:

DEPT   NAME            SAL      RESETSUM    RUNSUM
----------------------------------------------------------
10      SMITH           1000   1000             1000
          JONES           1000   2000             2000
          KING             1000   3000             3000

20      JOHNSON       1500   1500             4500
          WARD           1000   2500             5500

The parent group, G_DEPT, contains the DEPTNO column.  The child group, G_EMP, contains ENAME and SAL.  To get the sum of salaries for each department (RESETSUM), you create a summary column in G_EMP with the following settings

Function        Reset At
Sum              G_DEPT
In this case, Reset At indicates that the summary should be set to null after each department.

To get the running sum of salaries (RUNSUM), you create a summary column in G_EMP with the following settings:

Function        Reset At
Sum    Report
In this case, Reset At indicates that the summary should not be reset to null but should accumulate throughout the report.


Value If Null
Description The Value if Null property is a value to be substituted for any null values of the column.  For example, if you enter X in this field for a character type column, then an X will be displayed for null values fetched for the column.  If left blank, no substitution will be done for null values.
Values Enter any valid value that conforms to the column's Data type.  Value if Null cannot exceed 1K in length.
Applies to columns
Required/Optional optional
Default blank
Usage Notes
Entering a string for Value if Null on a break column causes Report Builder to prefetch all of the rows in the break column's group.  This could degrade performance when you run the report.  To avoid pre fetching, use the NVL function in your query rather than entering a string for Value if Null.

About Data Model Columns


Data Base columns
Database columns represent a column that is selected by the query and contains the data values for a report. For each column that you select in your query, Reports Builder automatically creates a column in the data model of your report.


 Formula Columns
            Formula columns to create computed columns. It can be written using PL/SQL syntax. Formula columns names are generally preceded by “CF_” to distinguish them from data columns. A formula column performs a user-defined computation on the data of one or more column(s), including placeholder columns.
For example, : ITEMTOT *.07 is a formula that performs a computation on one column, while :SAL + :COMM performs a computation using two columns in a record. You create formulas in PL/SQL using the PL/SQL Editor.

Note: Formula columns should not be used to set values for parameters.

Creating or editing a formula column

To create or edit a formula column:
1.      In the Data Model view, single-click the Formula Column in the tool palette, then:
·         To create a column within a group, click in the group at the position you want the column placed in the hierarchy.
·         To create a report-level column, click in an open area of the canvas region.
2.      Double-click the formula column object to display the Property Inspector.
3.      Under the Placeholder/Formula node, double click the PL/SQL Formula property field.
In the PL/SQL Editor, define the PL/SQL for the formula for example SAL * 0.07. 











Summary Columns

            Summary columns perform a computation on another column’s data. These are used for calculating summary information like SUM,AVERAGE,COUNT,MINIMUM,MAXIMUM,%TOTAL. This column uses a set or predefined Oracle aggregate functions that can be applied to data or formula columns. Summary columns names are generally preceded by “CS_” to distinguish them from data columns.

Creating a summary column:

 To create a summary column (for totals or subtotals) using the Data Wizard:

Ø       In the Data Model view, click the query that contains the column you want to total.
Ø       Choose Tools―> Data Wizard.
Ø       On the Totals page, follow the wizard to add the desired summary to your report.

 Note: For group reports, the Report Wizard and Data Wizard create n summary fields in the data model for each summary column you define: one at each group level above the column being summarized, and one at the report level.   For example, if a report is grouped by division, and further grouped by department, then a summary column defined for a salary total would create fields for the sum of salaries for each division and each department group (group-level summaries), and the sum of all salaries (report-level summary).


To create a summary column (for totals or subtotals) using the tool palette:

Ø       In the Data Model view, single-click  in the tool palette, then:
o         To create a column within a group, click in the group at the position you want the column placed in the hierarchy.
o         To create a report-level column, click in an open area of the canvas region.

Ø       Double-click the summary column object to display the Property Inspector.
Ø       Under the Summary node:
o         Set the Function property by choosing the type of summary you want from the list.
o         Set the Source property to the column you want to summarize.
o         Set the Reset At property to the group at which the summary column value resets.


Place Holders

            A placeholder is a column for which we set the data type and value in PL/SQL that we define. Placeholder columns are useful when you want to selectively set the value of a column (E.g.: each time the nth record is fetched, or each time a record containing a specific value is fetched, and so on). We can set the value of a placeholder column in the following places:
§          the Before Report Trigger, if the placeholder is a report-level column
§          a report-level formula column, if the placeholder is a report-level column
§          a formula in the placeholder's group or a group below it (the value is set once for each record of the group)
           
Creating or editing a placeholder column
To create or edit a placeholder column:
1.      In the Data Model view, single-click the Placeholder Column tool in the tool palette.
·         To create a column within a group, click in the group at the position you want the column placed in the hierarchy.
·         To create a report-level column, click in an open area of the canvas region.
2.      Double-click the placeholder column object.
3.      In the Property Inspector, set the desired properties for the placeholder column.
4.      Set the value of a placeholder column in:
·         the Before Report trigger, if the placeholder is a report-level column
·         a report-level formula column, if the placeholder is a report-level column
·         a formula in the placeholder's group or a group below it (the value is set once for each record of the group)