473,789 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating an Average over multiple fields

1 New Member
Good afternoon,

I am trying to calculate an average over multiple fields. I've tried using the following

=Avg(IIF([Score A] = "NA",Null, Val([Score A]))) + Avg(IIF([Score B] = "NA",Null, Val([Score B]))) + Avg(IIF([Score C] = "NA",Null, Val([Score C])))

The above, [Score A], [Score B], etc. are text fields pertaining to an evaluation rating scale:

NA 1 2 3 4 5

I would like to calculate an average over all the evaluation questions. The AVG formula ignores Null Values which is why i am trying to get the expression to set the value to NULL when NA is entered, meaning that the question does not apply and therefore it will not be included in the AVG calculation. I use VAL because of the fact that i have the field set to text.

Please help, i am not able to find a solution to this problem.

Thanks in advance for your efforts and help.

My operating system is XP and this is for Access 2003.

Rene
Jul 30 '07 #1
2 6376
puppydogbuddy
1,923 Recognized Expert Top Contributor
Good afternoon,

I am trying to calculate an average over multiple fields. I've tried using the following

=Avg(IIF([Score A] = "NA",Null, Val([Score A]))) + Avg(IIF([Score B] = "NA",Null, Val([Score B]))) + Avg(IIF([Score C] = "NA",Null, Val([Score C])))

The above, [Score A], [Score B], etc. are text fields pertaining to an evaluation rating scale:

NA 1 2 3 4 5

I would like to calculate an average over all the evaluation questions. The AVG formula ignores Null Values which is why i am trying to get the expression to set the value to NULL when NA is entered, meaning that the question does not apply and therefore it will not be included in the AVG calculation. I use VAL because of the fact that i have the field set to text.

Please help, i am not able to find a solution to this problem.

Thanks in advance for your efforts and help.

My operating system is XP and this is for Access 2003.

Rene
Try this and see if it helps:

=Avg(IIF([Score A] = "NA","", Val(Nz([Score A],"")))) + Avg(IIF([Score B] = "NA","", Val(Nz([Score B],"")))) + Avg(IIF([Score C] = "NA","", Val(Nz([Score C],""))))
Aug 6 '07 #2
ADezii
8,834 Recognized Expert Expert
Good afternoon,

I am trying to calculate an average over multiple fields. I've tried using the following

=Avg(IIF([Score A] = "NA",Null, Val([Score A]))) + Avg(IIF([Score B] = "NA",Null, Val([Score B]))) + Avg(IIF([Score C] = "NA",Null, Val([Score C])))

The above, [Score A], [Score B], etc. are text fields pertaining to an evaluation rating scale:

NA 1 2 3 4 5

I would like to calculate an average over all the evaluation questions. The AVG formula ignores Null Values which is why i am trying to get the expression to set the value to NULL when NA is entered, meaning that the question does not apply and therefore it will not be included in the AVG calculation. I use VAL because of the fact that i have the field set to text.

Please help, i am not able to find a solution to this problem.

Thanks in advance for your efforts and help.

My operating system is XP and this is for Access 2003.

Rene
Anytime that you are using the IIf() Function in conjunction with possible NULL values, you are literally playing with fire because of the inefficiency of IIf() and the usual NULL problems.
Aug 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
9484
by: Stephen Miller | last post by:
Firstly, sorry for the long post, but I've included a fair bit of sample data. Im doing a comparision of 10yr Bond prices and CPI adjustments, with an 18 week moving average of the CPI. I'm using a nested sub-query to calculate the moving average, but I'm having difficulty selecting exactly 18 data points (ie When I include the 'HAVING COUNT(C1.Closes) = 18' line, I get no results). Can anyone help?
7
2182
by: JLM | last post by:
I have a table that has fieldA, fieldB, fieldC. I want fieldC=fieldA-fieldB. simple enough. the next record I want to be able to do the same on the new value of fieldC. I can do this with SAP ABAP/4, but have never done this using Access. I'm sure this can be done, but not sure how to go about it. thanks in advance, jlm
1
2380
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on this form. Any employee can have multiple entries in the table (key fields are EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual leave, then take 3 days sick leave in any given month. I have a BeginningBalance of hours that...
2
13608
by: Wayne Aprato | last post by:
I've read most, if not all, of the posts on moving average and still can't find a simple solution to my problem (if a simple solution exists!) I have a table with 2 fields: Hours and Injuries. I have a query based on this table which shows these 2 fields and calculates a third field: Frequency Rate, based on a formula which uses the Hours and Injuries fields. Is there a simple way of A: using yet another calculated field in the query...
5
2627
by: jl2886 | last post by:
I have four fields in my table that I want to average providing the fields have a value, not the null, for each case(id). I also have an average field in my table. I have a form for the table and I want the average value to be populated on click with the average of the four fields. How can I do this?
5
2017
by: ye2127 | last post by:
Hi, I have two fields in my report. One of them is school name(the school name appears multiple times). The other field is class test score. How would I go about calculating the test average for each school? I can calculate the average of all the schools but am having difficulty coding some kind of sort procedure for an average test score of all the classes in each school. Thanks...
1
1518
by: ye2127 | last post by:
Hi, I have two fields in my report. One of them is school name(the school name appears multiple times). The other field is class test score. How would I go about calculating the test average for each school?(In a report) I can calculate the average of all the schools but am having difficulty coding some kind of sort procedure for an average test score of all the classes in each school. Does someone know the code for such a procedure?...
1
3513
kmartinenko
by: kmartinenko | last post by:
I have a table with over 12,000 entries. I have created a form (with the help of this forum) that will return the search results based upon the stop and stop time selected. See post http://www.thescripts.com/forum/thread757933.html for additional context. Now, I want to take this a step further by querying this table by clicking a new command button on the form which will open up a new query displaying the average number for six of these...
1
3554
by: cmb3587 | last post by:
My code runs fine for the most part...the only time it fails is when I type in a negative to end the array. I don't want the negative number to be included in the array and I thought that is what the while loop in the getNums method does. However, it is including this negative number when calculating the avg and it is doing something weird to the median. When the array end itself because the max size has been reached everything works fine. ...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.