Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compute a Sparse Average
Message
From
10/02/2009 16:23:39
 
 
To
10/02/2009 15:22:35
Ken Knorr
Logos Management Software
Ventura, California, United States
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01380665
Message ID:
01380701
Views:
75
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform