How Do I Add A Grand Total Function?
This example assumes you have completed the previous sections "How Do I Use Formulae For Basic Calculation Inside My DataGrid?" and have saved the stack to use here.
The Grand Total Function can be applied on a column by column basis and requires the addition of a field, external to the data grid, to display the result.
Select A Column
Open the DGH's Column builder, select the column 3 (1) , and expand the Formula topic to access the Grand Total Function (2).
Select A Function
Click on the Grand Total Function menu.
Note we have several functions ready to use with DGH: Sum, Min, Max, Average, Variance.
We have also functions for counting empty rows in a column, NAN (not a number) rows in a column (strings we can't use in numerical calculations) and finally cells containing numbers.
Select the SUM function.
Provide A Result Field
The calculations made are in addition to, and distinct from, the actual data in the data grid.
In order to display them, we will need a text field outside the data grid.
Create a new label field and place it below column 3 of the data grid.
The script installed by DGH which is doing calculation expects this ‘result’ field to be named according to the following convention: FunctionType_ColumnName
Where FunctionType is the chosen function, "_" is the underscore character and ColumnName is the name of the column we assigned the function.
As we have selected the SUM function for column "Col3", name the field: Sum_Col3
Test The Result
To test the result of our implementation just change the cell contents of one of the rows inside the data grid.
Going Further With Grand Total Functions
Note: the Formulae and Grand Total Functions are independent of each other.
This means you can have a Grand Total Functions associated with a column even it has no formula defined.
To complete this example we will add a MAX function to column 1 (which is without formula.)
And for column 2 we will add the MIN function.
This is also a good time to change the content alignment of each column to Right (1), for a better visual result inside the data grid.
Once this alignment is set for EACH column, apply the change to the data grid by clicking the Apply button (2).
This is also a good time to change the content alignment of each column to Right (1), for a better visual result inside the data grid.
Once this alignment is set for EACH column, apply the change to the data grid by clicking the Apply button (2).
Change the name of the the column 1’s summary field to "Max_Col1"
Change the name of the the column 2’s summary field to "Min_Col2".
Click on the stack, select the “Browse” tool and change one of the cell values in either column 1 or 2 and see the result in the relevant summary field.
0 Comments
Add your comment