susantrider
asked on
AVG() or SUM() in different fields with nulls
I have used Avg() to calculate the average of valus in a single field that may contain null values. Now I want to calculate the average of 5 values that are in different fields. It is possible that some of these values can be null and I will not want to include these in the average. In this case when I try to add the 5 values when one of them is null I come up with a null value. Can anyone help me wiht this? Thanks in advance.
Susan
Susan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Paasky, you have helped me agian. Thanks. The other answer was also helpful. Thank you!
Always happy to help you Susan. :o)
Best regards,
Paasky
Best regards,
Paasky
For each field in fields
if not IsNull(field)
SUM = SUM + field
intNbrValues = intNbrValues + 1
end if
next
AVG = SUM/intNbrValues