PC Review


Reply
Thread Tools Rate Thread

Counting only values greater than Zero

 
 
=?Utf-8?B?cmJiMTAx?=
Guest
Posts: n/a
 
      7th Nov 2006
I have a form that includes numerious questions with rating scales from 0-4.
If someone enters a Zero, this represents "not applicable". Therefore I want
to exclude this entry from my calculations. I have an unboud box to
calculate the average for all the ratings, but a need a forumla that will
only count those values that are greater than zero, or that are not zero. In
otherwords, I need to exclude all the zeros or "not applicables" from the
denominator in the averages calculation.
 
Reply With Quote
 
 
 
 
kingston via AccessMonster.com
Guest
Posts: n/a
 
      7th Nov 2006
Create a query based on this form's dataset where the criteria for rating is
<>0. The number of records in the query will be the denominator.

rbb101 wrote:
>I have a form that includes numerious questions with rating scales from 0-4.
>If someone enters a Zero, this represents "not applicable". Therefore I want
>to exclude this entry from my calculations. I have an unboud box to
>calculate the average for all the ratings, but a need a forumla that will
>only count those values that are greater than zero, or that are not zero. In
>otherwords, I need to exclude all the zeros or "not applicables" from the
>denominator in the averages calculation.


--
Message posted via http://www.accessmonster.com

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      7th Nov 2006
I assume it’s the average of ratings per record, not the averages of each
field over the set of records you want. If so the first thing I'd suggest is
that you identify the controls on the form to be used for the calculation by
setting the Tag property of each to CountMe.

Then add a function to the form's module:

Private Function AvgRating() As Double

Dim ctrl As Control
Dim intCount As Integer, intRating As Integer

For Each ctrl In Me.Controls
If ctrl.Tag = "CountMe" Then
If ctrl > 0 Then
intCount = intCount + 1
intRating = intRating + ctrl
End If
End If
Next ctrl

If intCount > 0 Then
AvgRating = intRating / intCount
End If

End Function

The set the ControlSource property of an unbound text box to:

=AvgRating()

Performance probably won't be lightning fast, however. It looks to me like
you are only having to resort to this because of a fundamental flaw in the
design; a very common one with databases of this type as it happens. Rather
than having multiple columns, one for each question, a correct design would
be to have multiple rows in a related table with columns Question
(referencing the key of a Questions table) and Answer, plus a foreign key
column referencing your current table. You can then use simple aggregating
queries to analyse the data.

Ken Sheridan
Stafford, England

"rbb101" wrote:

> I have a form that includes numerious questions with rating scales from 0-4.
> If someone enters a Zero, this represents "not applicable". Therefore I want
> to exclude this entry from my calculations. I have an unboud box to
> calculate the average for all the ratings, but a need a forumla that will
> only count those values that are greater than zero, or that are not zero. In
> otherwords, I need to exclude all the zeros or "not applicables" from the
> denominator in the averages calculation.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting numbers greater or less than a number =?Utf-8?B?a2lwcGVycw==?= Microsoft Excel Worksheet Functions 3 2nd Jul 2007 10:30 AM
Counting Consecutive cells in a row with a value greater than zero - how? SeanMc Microsoft Excel Discussion 4 31st May 2007 05:49 PM
Advanced Filter for Values in Column M greater than Values in Colu =?Utf-8?B?U3RldmVD?= Microsoft Excel Misc 3 2nd May 2006 07:55 PM
Counting dates greater than a certain time period theseandavis@gmail.com Microsoft Excel Worksheet Functions 7 26th Apr 2006 11:25 PM
Re: Counting dates that are greater or less than the current date Anon Microsoft Excel Worksheet Functions 0 2nd Jul 2003 03:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:14 PM.