If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Averages
I need to create a query that will give me averages on a list of numbers.
How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
#2
|
|||
|
|||
One post per question, please.
-- Rick B "Robert" wrote in message ... I need to create a query that will give me averages on a list of numbers. How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
#3
|
|||
|
|||
You could do two queries. One to exclude what you don't want in the calc,
then the second to perform the calc. Steve Clark, Access MVP FMS, Inc "Robert" wrote: I need to create a query that will give me averages on a list of numbers. How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
#4
|
|||
|
|||
MyAverage: Avg(IIF(TheField=0,Null,TheField)) Robert wrote: I need to create a query that will give me averages on a list of numbers. How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
#5
|
|||
|
|||
Robert
Are all your values in the same field, multiple rows, or are you trying to average like you might a spreadsheet (multiple columns of numbers in the same row)? Regards Jeff Boyce Access MVP "Robert" wrote in message ... I need to create a query that will give me averages on a list of numbers. How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
#6
|
|||
|
|||
Hi,
SELECT AVG(fieldName) FROM tableName WHERE fieldName 0 will return 3.6. The WHERE clause is applied before the aggregations occurred. If you need a criteria to be applied AFTER the aggregation occurred, you use a HAVING clause. Most aggregate also remove the NULL (unknown) values from consideration. Hoping it may help, Vanderghast, Access MVP "Robert" wrote in message ... I need to create a query that will give me averages on a list of numbers. How can I calculate the averages, but ignore 0 or null values. Addtionally if I am ignoreing the 0 value I don't want the record field to factored in the average count. e.g. 5 0 2 4 In this senario I would want the averages to be be caluated on the 3 records with values in excess of 0., 5+2+4=11 11/3 =3.6 If I took the 0 value I would end up with an average of 11/4=2.75 Any help would be appreciated. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Average of averages | Office User | Setting Up & Running Reports | 9 | May 2nd, 2005 09:21 PM |
Fill Form then Query that Averages input | accessquestion | Using Forms | 0 | December 16th, 2004 11:31 PM |
Select a range of records for use in moving averages | daverinda | Running & Setting Up Queries | 2 | November 19th, 2004 09:45 PM |
Dates and Averages | Bill | Worksheet Functions | 0 | October 6th, 2003 11:28 PM |
Extracting Averages | Bill | Worksheet Functions | 1 | October 6th, 2003 05:30 PM |