Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compute a Sparse Average
Message
De
10/02/2009 16:23:39
Al Doman (En ligne)
M3 Enterprises Inc.
North Vancouver, Colombie Britannique, Canada
 
 
À
10/02/2009 15:22:35
Ken Knorr
Logos Management Software
Ventura, Californie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01380665
Message ID:
01380701
Vues:
76
>Does anyone have a way to compute a average of data in footer bands. Data with value of 0 should not be counted in average.
>
>In other words if data in shown in detail band is 16, 0, 0, 0 the average should be 16 not 4.

If you drive your report with a custom cursor, you could pre-compute the values in the SELECT - SQL or whatever else you're doing.

It's been so long since I used report variables I barely remember how to use them, but maybe you could do something like:

- define a report variable, say SparseCount
- for Value to store put in something like IIF( ColumnValue = 0, 0, 1 )
- initial value should be OK at zero
- reset the value at the appropriate grouping level
- calculation type would be "Sum"

This would give you the denominator.

You would define another simple report variable just to sum the values e.g. SumTotal

In the footer you put in IIF( SparseCount > 0, SumTotal / SparseCount, 0 ) (eliminates errors caused by divide by zero if no non-zero values in your report)
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform