Quantcast
Channel: Our ComponentOne » All Posts
Viewing all articles
Browse latest Browse all 14170

Reply To: Making averages exclude null/zeros

$
0
0

Hi

This strikes me as an excellent example of the fact that 'there are lies, damned lies and statistics’

Technically The avg enumeration that you are using is correct in reporting an average of $100. If you consult the help documentation for it it states;

Calculates the average of all values within the specified summary region (group, page or report).

The crucial point being that it is all values (0 and Null still constitute a value of sorts). What I think that you are in fact after is the Mean value (although I should say that I’m not certain of that). However there is no enumeration for that in Active reports so the only way that you will get what you want is to code it yourself in the report. You’ll need to count the number of positive values (or perhaps you just want values that are greater than zero) and then divide the sum total of the column by the count. That shouldn’t be too difficult to do in the detail format event of the report.

As to the point that you raise in your second post. This is a classic case of where you should use the sql function Coalesce in your sql query. Coalesce will essentially allow you to substitute a null value for a value of your choice. See the msdn documentation here:

http://msdn.microsoft.com/en-us/library/ms190349.aspx

HTH

Dom


Viewing all articles
Browse latest Browse all 14170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>