Adding summary statistics – PB Docs 2017

Adding summary statistics

One of the advantages of creating a grouped DataWindow object
is that you can have PowerBuilder calculate statistics for each
group. To do that, you place computed fields that reference the
group. Typically, you place these computed fields in the group’s
trailer band.

To add a summary statistic

  1. Select Insert>Control>Computed Field from the menu
    bar.

  2. Click in the Design view where you want the
    statistic.

    The Modify Expression dialog box displays.

  3. Specify the expression that defines the computed field
    (see below).

  4. Click OK.

    A shortcut to sum values

    If you want to sum a numeric column, select the column
    in Design view and click the Sum button in the Controls
    drop-down toolbar. PowerBuilder automatically places a
    computed field in the appropriate band.

Specifying the
expression

Typically, you use aggregate and other functions in your
summary statistic. PowerBuilder lists functions you can use in the
Functions box in the Modify Expression dialog box. When you are
defining a computed field in a group header or trailer band,
PowerBuilder automatically lists forms of the functions that
reference the group:

filt19.gif

You can paste these templates into the expression, then
replace the #x that is pasted in as the function argument with the
appropriate column or expression.

For example, to count the employees in each department (group
1), specify this expression in the group trailer band:

To get the average salary of employees in a department,
specify:

To get the total salary of employees in a department,
specify:

The group trailer band in this example shows the average and
total salary for the group.

filt20.gif

At runtime, the average and total salaries are calculated and
displayed:

filt21.gif


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x