Re: Dividing one Control by another Control to find the Average.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The core point I was trying to make was the bit about Null
values being ignored. Your Count expression is counting
every record whether the field contains Null or not. Try my
expression for counting.

In addition your statement of "without much luck" doesnt'
really tell me what problem you are talking about so you may
be struggling with additional issues that are not apparent
in your post.

It may (or may not) be important to avoid using the Val
function because it can do things you might expect. If the
stitch values are integer or long type, then I suggest that
you use the Int function instead:
=Sum(Int([Header Stitch #1])) + Sum(Int([Header Stitch #2]))
+ Sum(Int([Header Stitch #3])) + Sum(Int([Header Stitch
#4])) + SumInt(([Header Stitch #5]))

Note that all these calculation need to be done in the same
footer section.

If all of that does not take care of it, then post back with
more details about the result you are seeing.
--
Marsh
MVP [MS Access]


Hoopster wrote:
The Data in my Table is Text. That's the reason I used the Val Funtion.
I am getting the correct numbers for my Sum and Count. My delima is when
trying to divide the Sum Value by the Count Value. I am trying to do the
division in the Style Footer.

"Marshall Barton" wrote:

Hoopster wrote:
I am trying to divide one Control, call it Text 1 by another Control
Text 2 to find the average of several entries in a Access Report. I am
placing the Controls in the the Style Footer where I am adding the Values of
Control One and Counting the Number of entries in Control 2.

Control 1 - =Sum(Val(nz([Header Stitch #1])))+Sum(Val(nz([Header Stitch
#2])))+Sum(Val(nz([Header Stitch #3])))+Sum(Val(nz([Header Stitch
#4])))+Sum(Val(nz([Header Stitch #5])))

Control 2 - =Count(IIf([Header Stitch #1] Is Not
Null,1,0))+Count(IIf([Header Stitch #2] Is Not Null,1,0))+Count(IIf([Header
Stitch #3] Is Not Null,1,0))+Count(IIf([Header Stitch #4] Is Not
Null,1,0))+Count(IIf([Header Stitch #5] Is Not Null,1,0))

I am trying to Divide Control 1 by Control 2 using =(Val([Text 1])/Val([Text
2])) without much luck.


Note that the aggregate functions (Count, Sum, etc) ignore
Null values so there is no need to check for Null or use the
Nz function. Assuming your data is appropriate and the
field names are correct, I think all you need is:

=Sum([Header Stitch #1]) + Sum([Header Stitch #2]) +
Sum([Header Stitch #3]) + Sum([Header Stitch #4]) +
Sum([Header Stitch #5])

=Count([Header Stitch #1]) + Count([Header Stitch #2]) +
Count([Header Stitch #3]) + Count([Header Stitch #4]) +
Count([Header Stitch #5])

Note that unless all those fields are Text type fields,
there is no need to use the Val function so I dropped that
too.

***Warning*** The use of field (not control) names such as
Stitch1, Stich2, ... is a red flag that the table structure
is not normalized and will cause no end of trouble.

--
Marsh
MVP [MS Access]


.



Relevant Pages

  • Re: Dividing one Control by another Control to find the Average.
    ... My count is counting every record whether or not it is ... Is Not Null,1,0))+Count(IIf([Header Stitch #3] Is Not ... I am getting the correct numbers for my Sum and Count. ... Control One and Counting the Number of entries in Control 2. ...
    (microsoft.public.access.reports)
  • Re: Dividing one Control by another Control to find the Average.
    ... Is Not Null,1,0))+Count(IIf([Header Stitch #3] Is Not ... I am getting the correct numbers for my Sum and Count. ... division in the Style Footer. ... Control One and Counting the Number of entries in Control 2. ...
    (microsoft.public.access.reports)
  • Re: counter/timer high resolution
    ... I believe what is going on is that you are using software timing to control ... You are controlling the counting by how long it ... What I believe you want to do is actually pause triggering, ... example finder under Hardware Input and Output»DAQmx»Counter ...
    (comp.lang.labview)
  • Re: result of GTT
    ... drunk for 40 years, but who's counting). ... My fasting value shortly after getting up was 122 but when I retested at ... lab right before their test it was already 142, ... hopefully get this thing under control. ...
    (alt.support.diabetes)
  • RE: Line at bottom of Detail section
    ... I never trust "code that is counting the times the detail section is firing". ... I have never had issues with running sums in controls and have answered ... Control Source: =Count ...
    (microsoft.public.access.reports)