 SAP Knowledge Base Article - Public

# 1205446- How to calculate a Geometric Mean

### Symptom

How do you display the Geometric Mean of a set of data points when Crystal Reports does not have this function?

### Resolution

The basic formula for calculating a Geometric Mean is Exp(Log(X)/N), where X is the product of the data points and N is the count of the data points.  Following the basic structure of the manual running total, a series of three formulas can be used to determine and display the Geometric Mean. The formulas must process in the WhilePrintingRecords phase so the results must be displayed in a footer and not in a header. To display a Geometric Mean perform the following steps:

1. Go to Start > Programs > Crystal Reports XI and open the report.
2. In the appropriate header insert the formula:

//@Geometric Mean - Initialize

//This formula should go in the header (group, report)
//for the set of data points involved in the calculation

whileprintingrecords;
numbervar product := 1;
numbervar counter := 0;

1.  In the same section level insert the formula:

//@Geometric Mean - Evaluate

//This formula should go in the same section level (details, group
//footer) of the set of data points involved in the calculation

whileprintingrecords;
numbervar counter := counter + 1;
numbervar product := if {table.numericfield} <> 0 then (product * {table.numericfield};) else product;

1.  In the appropriate footer insert the formula:
//Geometric Mean - Display

//This formula should go in the footer (group, report)
//for the set of data points involved in the calculation

whileprintingrecords;
numbervar product;
numbervar counter;

Exp(Log(product)/counter);

### Keywords

Geometric Mean , 8401675 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

### Product

SAP Crystal Reports XI ; SAP Crystal Reports XI R2