Xceed Grid for WinForms v4.3 Documentation
How to display running sums

Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Appearance > How to display running sums

The SummaryRow and SummaryCell classes can be used to display the results of statistical functions (including running sums). Statistical results, wether running or not, can be displayed as is (25, 2.4, etc.), or in a descriptive manner ("The average freight is $2.4"). 

If a SummaryCell's StatFunction property is set, the result of the statistical function will be displayed, as is, in the SummaryCell. A title for the statistical result can be provided using the TitleFormat property. This property supports variables which are resolved to displayed various dynamic information including, among other things, the name of the column whose values are used to calculate the result and the actual result of the statistical function. 

The SummaryRow's TextFormat property allows for a summary to be displayed across the entire SummaryRow. If the TextFormat property of a SummaryRow is set and one or more cell's also have a string assigned to their TitleFormat properties, there is a chance that the SummaryRow's text and the SummaryCells' titles will overlap. It is also possible to experience this behavior anytime a SummaryCell's StatFunction property is different than StatFunction.None.

Running statistical functions

In order to display running stats/sums, the RunningStatGroupLevel property of the SummaryRow or SummaryCell must be set. 

If 0 is specified, the running stat will be calculated for all the groups in the grid. If 1 is specified, the running stat will be calculated for all groups of level 1. In otherwords, all the level 1 groups beneath the parent level 0 group. Keep in mind that the value of the running statistical function will be the accumulation of the values found before the current SummaryCell/Row. 

If the RunningStatGroupLevel property is assigned a value that is greater than its parent group's level, the result will be the same as if the RunningStatGroupLevel property was set to -1; no running stat. 

If a SummaryCell/Row is contained in a detail grid or one of its child groups, its running stat will be contained within the scope of the detail grid. This means that a SummaryCell/Row cannot calculate a running statistical function across multiple (run-time) detail grids.   

Demonstration

The following example demonstrates how to display the results of a running statistical function through a descriptive text.    

Of course, a simple statistical result could also be displayed, by cell, by setting the StatFunction and (optionally) TitleFormat properties.

VB.NET
Copy Code
CType( sumRow.Cells( "ProductAmount" ), SummaryCell ).StatFunction = StatFunction.Average
CType( sumRow.Cells( "ProductAmount" ), SummaryCell ).TitleFormat = "The average product amount is:"
C#
Copy Code
( ( SummaryCell )sumRow.Cells[ "ProductAmount" ] ).StatFunction = StatFunction.Average;
( ( SummaryCell )sumRow.Cells[ "ProductAmount" ] ).TitleFormat = "The average product amount is:";

The following table provides a list of the supported statistical functions: 

Statistical Function Description
Minimum The value of the item with the lowest value among a set of items.
 
If a object that implements the IComparable interface is assigned to the DataComparer property of the column represented by StatFieldName, it will be used to calculate the minimum value.
Maximum The value of the item with the highest value among a set of items.
 
If a object that implements the IComparable interface is assigned to the DataComparer property of the column represented by StatFieldName, it will be used to calculate the maximum value.
Count The result of a tally that reveals the number of items in a set.
Sum The result of the addition of the values of a set of items.
Average The measure of central tendancy of a set of values computed by dividing the sum of the values by their number; commonly called the arithmetic mean or the average.
Variance The variance of a random sample variable is a non-negative number which gives an idea of how widely spread the values of the random variable are likely to be; the larger the variance, the more scattered the observations on average.
VariancePopulation The variance of a random population variable is a non-negative number which gives an idea of how widely spread the values of the random variable are likely to be; the larger the variance, the more scattered the observations on average.
StandardDeviation A measure of the degree of dispersion of sample data from the mean value.
StandardDeviationPopulation A measure of the degree of dispersion of population data from the mean value.
Median The middle number in a set of ordered data. If the set contains an even number of items, the arithmetic mean of the 2 middle values will be returned.
Mode The value that has the largest number of observations, namely the most frequent value or values. The mode is not necessarily unique, unlike the arithmetic mean.
 
The mode can be calculated for any type of data. In the case of a multimodal set of values, only one of the mode will be returned. Ex. : [1, 2, 2, 6, 6] is bimodal (2 and 6) and the function will return either 2 or 6.
 
Nothing will be returned if all the items in the set are unique.
HarmonicMean The number of elements to be averaged divided by the sum of the reciprocals of the elements.
 
The harmonic mean can only be calculated on elements whose values are greater than 0. If the set contains an element whose value is less than or equal to 0, then OverflowText will be displayed.
GeometricMean The geometric mean of a set of positive data is defined as the product of all the members of the set, raised to a power equal to the reciprocal of the number of members.
 
The geometric mean can only be calculated on elements whose values are greater than 0. If the set contains an element whose value is less than or equal to 0, then OverflowText will be displayed.
RootMeanSquare The square root of the arithmetical average of a set of squared instantaneous values. The root mean square is also known as the quadratic mean.
In statistics, a statistical population is a set of entities concerning which statistical inferences are to be drawn, often based on a random sample taken from the population. For example, if we were interested in generalizations about crows, then we would describe the set of crows that is of interest. Notice that if we choose a population like all crows, we will be limited to observing crows that exist now or will exist in the future. Probably, geography will also constitute a limitation in that our resources for studying crows are also limited. 

"Population" is also used to refer to a set of measurements or values. Suppose, for example, we are interested in the set of all adult crows now alive in the county of Kent, and we want to know the mean weight of these birds. For each bird in the population of crows there is a weight, and the set of these weights is called the "population of weights". 

A sample is that part of a population which is actually observed. In normal scientific practice, we demand that it be selected in such a way as to avoid presenting a biased view of the population. If statistical inference is to be used, there must be a way of assigning known probabilities of selection to each sample. If the probabilities of different samples are all equal, for example, the method is called simple random sampling. 

Information taken from http://en.wikipedia.org