473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Average of strings

I have several queries, which generate about 10 fields each a text
field of length 2 (which contain effort and attainment grades), eg A2,
B4, A3, A3. I am trying to calculate an 11th fields, which is an
average of the other fields (in this case A3). Does anyone have any
ideas?

Tony Lennard
Nov 13 '05 #1
3 1794
Can you assign a numeric value to each text value, do the average, and then
lookup what text value is closest to the numeric average?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Tony Lennard" <to**@lennarda. freeserve.co.uk > wrote in message
news:9c******** *************** ***@posting.goo gle.com...
I have several queries, which generate about 10 fields each a text
field of length 2 (which contain effort and attainment grades), eg A2,
B4, A3, A3. I am trying to calculate an 11th fields, which is an
average of the other fields (in this case A3). Does anyone have any
ideas?

Tony Lennard

Nov 13 '05 #2
Tony Lennard wrote:
I have several queries, which generate about 10 fields each a text
field of length 2 (which contain effort and attainment grades), eg A2,
B4, A3, A3. I am trying to calculate an 11th fields, which is an
average of the other fields (in this case A3). Does anyone have any
ideas?

Tony Lennard


I might create another query. Drop in the query you created and drag
all fields or the * to it.

Create another column. Enter something like
AvgOfThe10 : GetAvg([Col1], [Col2]...[Col10])

This will call the function, contained in a module, called GetAvg.

Now, I suppose an A is greater than a B and so on. In the function, you
could get the left value. Let's assign A=5, B = 4...F = 1.

Now add the left value times 10 plus the right value
A3 = 5 * 10 + 3
53
B4 = 4 * 10 + 4
44

So now you add up all of the numbers and divide by 10 to get the average.

Let's say you had all 9 A1's and 1 A2. The number you would get would
be 583. Ex (59*9) + (52*1)

The average would be 58.

Now you calc for the letter. Int(58/10) = 5. So you determine that is
an A.

You can subract 58-(5*10) to get 8. Thus the average is A8.

Public Function GetAvg(v1, v2, v3....v10) As String
Dim intNumber As Integer
Dim intAvg As Integer
Dim intRemain As Integer
Dim intLetter As Integer
'get the total
intNumber = intNumber + (ParseValue(v1) *10) + Cint(Right(V1,1 ))
intNumber = intNumber + (ParseValue(v2) *10) + Cint(Right(V2,1 ))
intNumber = intNumber + (ParseValue(v3) *10) + Cint(Right(V3,1 ))
intNumber = intNumber + (ParseValue(v4) *10) + Cint(Right(V4,1 ))
...
'583 using the example above
intNumber = intNumber+(Pars eValue(v10)*10) + Cint(Right(V10, 1))

'get the average...58
intAvg = Int(intNumber / 10)

'we have 10 items we are avging and we multiplied by 10
'the letter so...83
intRemain = intNumber Mod 100

'get the letter...A
GetAvg = ParseAlpha(intA vg)

'note...Cint does rounding.
'Cint(80..85/10) = 8
'Cint(86..89/10) = 9
GetAvg = GetAvg & CInt(intRemain/10)

'this will return A8 to the column in the query

End Function
Public Function ParseValue(var)
Select case Left(var,1)
Case "A"
ParseValue = 5
Case "B"
ParseValue = 4
Case "C"
ParseValue = 3
Case "D"
ParseValue = 2
case else
ParseValue = 1
end select
End Function
Public Function ParseAlpha(var)
'we divide by 10 because A = 5*10 = 50
Select case Int(var/10)
Case 5
ParseAlpha = "A"
Case 4
ParseAlpha = "B"
Case 3
ParseAlpha = "C"
Case 2
ParseAlpha = "D"
case else
ParseAlpha = "E"
end select
End Function
Nov 13 '05 #3
"Tony Lennard" <to**@lennarda. freeserve.co.uk > wrote in message
news:9c******** *************** ***@posting.goo gle.com...
I have several queries, which generate about 10 fields each a text
field of length 2 (which contain effort and attainment grades), eg A2,
B4, A3, A3. I am trying to calculate an 11th fields, which is an
average of the other fields (in this case A3). Does anyone have any
ideas?


If your design is normalized you should have the attainable grades in a
separate table. Just add another column to the table to hold the numeric
score vales.
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4405
by: Sara | last post by:
I am trying to find the average number of products of the set that is on rows...dynamically. For example, if I had states on rows and was looking at the average number of products, I would see this IN 72 MI 66 AL 88
6
3137
by: J | last post by:
Kind of new at programming/vb.net. I'm doing this junky die roller program. Heres's what is supposed to happen: Roll 2 6-sided dies. Add rolls together put total in rolls(d6total). Display the number of 2 or 12 rolled, then display those numbers and average rolls. I didn't know how to do it exactly, but I came up with this.
4
3409
by: Gary | last post by:
Hi, I have a temperature conversion program down pat, but I was told to add an average, meaning, i need to get the average temperature for as many times as it was entered. i do not know where to start, and my stpid book doesnt seem to help. here is my program #include <iostream.h> void main( ) {
3
2317
by: C++Geek | last post by:
I need to get this program to average the salaries. What am I doing wrong? //Program to read in employee data and calculate the average salaries of the emplyees.
2
7163
by: jarosciak | last post by:
Hi everyone, I need a little bit of help with this problem. I've got a time durations feed, which comes in this format (minutes:seconds): Example, there is only 5 values:
8
1875
by: Allan Ebdrup | last post by:
What would be the fastest way to search 18,000 strings of an average size of 10Kb, I can have all the strings in memory, should I simply do a instr on all of the strings? Or is there a faster way? I would like to have a kind of search like google where you can enter several words to search for, guess that calls for a regular expression "word1|word2|word3|...". Is there any kind of indexing tools available for this kind of thing, I have my...
3
4143
by: mochatrpl | last post by:
I am looking for a way to make a query / report display the running average for total dollars. I have already set up a query to provide totals dollars per day from which a report graphly shows the dollars per week. How do I then take the dollars and get a running average for the year? - Randy
3
5308
by: Salad | last post by:
http://www.mathwords.com/w/weighted_average.htm At the above link gives an example of a weighted average. It uses the following example: Grades are often computed using a weighted average. Suppose that homework counts 10%, quizzes 20%, and tests 70%. If Pat has a homework grade of 92, a quiz grade of 68, and a test grade of 81, then
5
3183
by: p3rk3le | last post by:
So, I'm about to do a sequential search on a table (n contents) of random numbers. I have to print the average between the number of comparisons and the contents of the table (n) and the average time for each sequential search. I wrote:
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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
10225
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
10053
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...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
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
5312
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...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3573
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.