Calculating averages

  • Thread starter Thread starter Labjoan
  • Start date Start date
L

Labjoan

Access 2003 Using the following formula:=DateDiff("d", [Date In], [Date
Completed]) I have calculated the number of days it takes for repair on a
particular model. I'm having a problem creating a control that will give me
the average # of days it takes for all repairs. I have a grouping level of
Model's so I would be putting the formula in for each Model as well as the
total. Any ideas?
 
Since you can't use Aggregate functions on controls in a report, you will
need to move your calculation to the report's record source query. Then in
your detail section, you will need to make that calculated field the control
source of the text box where you show the number of days.
To average it by group, you would need a control in the Group footer to do
the average on the field:

=Avg([CalculatedField])
 
Glad to help. Now, one caution. This is a special circumstance that
requires the calculation be done at the query level. Normally, you want to
do you calculations at the report level. It is much faster. There are
times, and this is one, where it requires the calculation be done at the
query level.
--
Dave Hargis, Microsoft Access MVP


Labjoan said:
Worked great! Thanks for the excellent suggestion

Labjoan said:
Access 2003 Using the following formula:=DateDiff("d", [Date In], [Date
Completed]) I have calculated the number of days it takes for repair on a
particular model. I'm having a problem creating a control that will give me
the average # of days it takes for all repairs. I have a grouping level of
Model's so I would be putting the formula in for each Model as well as the
total. Any ideas?
 
Dave is correct (as usual). You can also try the following in a control
source in a group or report section:
=Avg(DateDiff("d", [Date In], [Date Completed]))

--
Duane Hookom
Microsoft Access MVP


Klatuu said:
Since you can't use Aggregate functions on controls in a report, you will
need to move your calculation to the report's record source query. Then in
your detail section, you will need to make that calculated field the control
source of the text box where you show the number of days.
To average it by group, you would need a control in the Group footer to do
the average on the field:

=Avg([CalculatedField])
--
Dave Hargis, Microsoft Access MVP


Labjoan said:
Access 2003 Using the following formula:=DateDiff("d", [Date In], [Date
Completed]) I have calculated the number of days it takes for repair on a
particular model. I'm having a problem creating a control that will give me
the average # of days it takes for all repairs. I have a grouping level of
Model's so I would be putting the formula in for each Model as well as the
total. Any ideas?
 
Doh!
Better. It takes the calculation out of the query.
--
Dave Hargis, Microsoft Access MVP


Duane Hookom said:
Dave is correct (as usual). You can also try the following in a control
source in a group or report section:
=Avg(DateDiff("d", [Date In], [Date Completed]))

--
Duane Hookom
Microsoft Access MVP


Klatuu said:
Since you can't use Aggregate functions on controls in a report, you will
need to move your calculation to the report's record source query. Then in
your detail section, you will need to make that calculated field the control
source of the text box where you show the number of days.
To average it by group, you would need a control in the Group footer to do
the average on the field:

=Avg([CalculatedField])
--
Dave Hargis, Microsoft Access MVP


Labjoan said:
Access 2003 Using the following formula:=DateDiff("d", [Date In], [Date
Completed]) I have calculated the number of days it takes for repair on a
particular model. I'm having a problem creating a control that will give me
the average # of days it takes for all repairs. I have a grouping level of
Model's so I would be putting the formula in for each Model as well as the
total. Any ideas?
 
Can you help me with a problem. I have a calculated field at query level. It
is KPL: Total Miles/Total Fuel Used. I am trying to get an average for each
driver in a report based on the query. But it asks for KPL whenever i run the
report and then obviously returns a blank field with no errors reported. I
have tried going back to the query and click on average in the totals but it
asks me for KPL when i run the query. What am i doing wrong?

Klatuu said:
Doh!
Better. It takes the calculation out of the query.
--
Dave Hargis, Microsoft Access MVP


Duane Hookom said:
Dave is correct (as usual). You can also try the following in a control
source in a group or report section:
=Avg(DateDiff("d", [Date In], [Date Completed]))

--
Duane Hookom
Microsoft Access MVP


Klatuu said:
Since you can't use Aggregate functions on controls in a report, you will
need to move your calculation to the report's record source query. Then in
your detail section, you will need to make that calculated field the control
source of the text box where you show the number of days.
To average it by group, you would need a control in the Group footer to do
the average on the field:

=Avg([CalculatedField])
--
Dave Hargis, Microsoft Access MVP


:

Access 2003 Using the following formula:=DateDiff("d", [Date In], [Date
Completed]) I have calculated the number of days it takes for repair on a
particular model. I'm having a problem creating a control that will give me
the average # of days it takes for all repairs. I have a grouping level of
Model's so I would be putting the formula in for each Model as well as the
total. Any ideas?
 
TinMan said:
Can you help me with a problem. I have a calculated field at query level. It
is KPL: Total Miles/Total Fuel Used. I am trying to get an average for each
driver in a report based on the query. But it asks for KPL whenever i run the
report and then obviously returns a blank field with no errors reported. I
have tried going back to the query and click on average in the totals but it
asks me for KPL when i run the query. What am i doing wrong?

Instead of using Avg(KPL), try:
Avg([Total Miles] / [Total Fuel Used])
 
I put the formula in the reg footer section. When i run the report it asks
for Total Miles / Total Ltrs in a parameter box. Do you know why? I have also
tried using the txtbox control name but it does the same thing. Cheers

Marshall Barton said:
TinMan said:
Can you help me with a problem. I have a calculated field at query level. It
is KPL: Total Miles/Total Fuel Used. I am trying to get an average for each
driver in a report based on the query. But it asks for KPL whenever i run the
report and then obviously returns a blank field with no errors reported. I
have tried going back to the query and click on average in the totals but it
asks me for KPL when i run the query. What am i doing wrong?

Instead of using Avg(KPL), try:
Avg([Total Miles] / [Total Fuel Used])
 
Please use Copy/Paste when posting a problem expression.

If you are being prompted to enter something, then that
something is not a field in the report's record source
query. Maybe you have an extra space, have the [ ] in the
wrong place or maybe you just misspelled the something.

If that's the expression you want to average, I would expect
the report text box's expression to be:
=Avg([Total Miles] / [Total Ltrs])
--
Marsh
MVP [MS Access]

I put the formula in the reg footer section. When i run the report it asks
for Total Miles / Total Ltrs in a parameter box. Do you know why? I have also
tried using the txtbox control name but it does the same thing. Cheers

Marshall Barton said:
Instead of using Avg(KPL), try:
Avg([Total Miles] / [Total Fuel Used])
 
Sorry i forgot to post my expression though it the same as yours
=Avg([Total Miles] / [Total Ltrs]). Though, like i say, it throws up the
parameter dialog box asking for a value for [Total Miles] then [Total Ltrs]
or LGP if i put
=Avg([LPG]). Both fields are derived from calculated fields in my query but
each have the record source from the query so dont undertand why it asking
for values when they there. I have created a footer but i dont get an #error
or #Name just a blank text box. Can you help me figure it out Dale???.
Incidently, this not the 1st time you help me. I needed a parameter date
query to find conflicting holiday requests by staff few months ago and you
got it spot on. I Thanked you but got no reply. But Thanx again. It actually
pretty good!!

Marshall Barton said:
Please use Copy/Paste when posting a problem expression.

If you are being prompted to enter something, then that
something is not a field in the report's record source
query. Maybe you have an extra space, have the [ ] in the
wrong place or maybe you just misspelled the something.

If that's the expression you want to average, I would expect
the report text box's expression to be:
=Avg([Total Miles] / [Total Ltrs])
--
Marsh
MVP [MS Access]

I put the formula in the reg footer section. When i run the report it asks
for Total Miles / Total Ltrs in a parameter box. Do you know why? I have also
tried using the txtbox control name but it does the same thing. Cheers

Marshall Barton said:
Instead of using Avg(KPL), try:
Avg([Total Miles] / [Total Fuel Used])
TinMan wrote:
Can you help me with a problem. I have a calculated field at query level. It
is KPL: Total Miles/Total Fuel Used. I am trying to get an average for each
driver in a report based on the query. But it asks for KPL whenever i run the
report and then obviously returns a blank field with no errors reported. I
have tried going back to the query and click on average in the totals but it
asks me for KPL when i run the query. What am i doing wrong?

.
 
TinMan said:
Sorry i forgot to post my expression though it the same as yours
=Avg([Total Miles] / [Total Ltrs]). Though, like i say, it throws up the
parameter dialog box asking for a value for [Total Miles] then [Total Ltrs]
or LGP if i put
=Avg([LPG]). Both fields are derived from calculated fields in my query but
each have the record source from the query so dont undertand why it asking
for values when they there. I have created a footer but i dont get an #error
or #Name just a blank text box. Can you help me figure it out Dale???.
Incidently, this not the 1st time you help me. I needed a parameter date
query to find conflicting holiday requests by staff few months ago and you
got it spot on. I Thanked you but got no reply. But Thanx again. It actually
pretty good!!


When you post a simple thanks to a post, it means that you
have solved your problem and no further discussion is
needed. A you're welcome reply does not add any value to
the thread and is considered a waste of bandwidth.

To your real problem. The aggregate functions (Count, Sum,
Avg, etc) are unaware of controls on a form/report (and
calculated fields in the same query) They ony know about
fields in the form/report's record source table/query. In
other words, you can not use things "derived from calculated
fields in my query", they must actually be straight from the
query. Use the expressions that were used to derive the
values.
 
Thank you for replying again, I take your point on bandwidth does that mean i
cant say thanks. How can i source the original values if my form is based on
a query would i need to use a dlookup. Sorry about the Dale bit he helping
with another problem. One last bit of waste bandwidth. How do i keep track of
my posts. I have asked microsoft but they not help. I find a post then click
my name and seach for recent posts but not ideal. Thanz

Marshall Barton said:
TinMan said:
Sorry i forgot to post my expression though it the same as yours
=Avg([Total Miles] / [Total Ltrs]). Though, like i say, it throws up the
parameter dialog box asking for a value for [Total Miles] then [Total Ltrs]
or LGP if i put
=Avg([LPG]). Both fields are derived from calculated fields in my query but
each have the record source from the query so dont undertand why it asking
for values when they there. I have created a footer but i dont get an #error
or #Name just a blank text box. Can you help me figure it out Dale???.
Incidently, this not the 1st time you help me. I needed a parameter date
query to find conflicting holiday requests by staff few months ago and you
got it spot on. I Thanked you but got no reply. But Thanx again. It actually
pretty good!!


When you post a simple thanks to a post, it means that you
have solved your problem and no further discussion is
needed. A you're welcome reply does not add any value to
the thread and is considered a waste of bandwidth.

To your real problem. The aggregate functions (Count, Sum,
Avg, etc) are unaware of controls on a form/report (and
calculated fields in the same query) They ony know about
fields in the form/report's record source table/query. In
other words, you can not use things "derived from calculated
fields in my query", they must actually be straight from the
query. Use the expressions that were used to derive the
values.
 
Like I said, a Thanks post indicates that your problem is
solved and further postings are not needed. Not saying
thanks (or better to say that the problem was solved and how
you solved it) leaves the thread kind of hanging with
everyone wondering if you need more help, got tired of it
all, had an accident, just don't care or ....

I don't use the (IMO dumb) web interface for newsgroups. I
use Forte Agent, which is designed around newsgroups and
email, so I have no idea what features the web interface has
that might help keep track of your threads. Even Outlook
Express has decent newsgroup features. In Agent, I just
leave my own posts marked as unread for a week and use the
Next Unread key to zip through looking for a question or
followup where I might be able to help.
--------------------------------------------------------------------------------------
You can use any record source field in a form/report
aggregate function regardless of how the field got into the
query. What you can not use is a control name from the
form/report. For example, if your record source query has
quantity and price fields and the price field is calculated
from some other info (e.g. base price, preferred customer,
etc), the form/report will see price as a field, no problem.

For example, if the detail section of the report has a [line
item total] text box with the expression =qty * price, the
form/report footer grand total text box can not use the
expression =Sum([line item total]). Instead, it can use
the expression:
=Sum(qty * price)
because qty and price come from the record source query.
--
Marsh
MVP [MS Access]

Thank you for replying again, I take your point on bandwidth does that mean i
cant say thanks. How can i source the original values if my form is based on
a query would i need to use a dlookup. Sorry about the Dale bit he helping
with another problem. One last bit of waste bandwidth. How do i keep track of
my posts. I have asked microsoft but they not help. I find a post then click
my name and seach for recent posts but not ideal. Thanz

Marshall Barton said:
When you post a simple thanks to a post, it means that you
have solved your problem and no further discussion is
needed. A you're welcome reply does not add any value to
the thread and is considered a waste of bandwidth.

To your real problem. The aggregate functions (Count, Sum,
Avg, etc) are unaware of controls on a form/report (and
calculated fields in the same query) They ony know about
fields in the form/report's record source table/query. In
other words, you can not use things "derived from calculated
fields in my query", they must actually be straight from the
query. Use the expressions that were used to derive the
values.
TinMan said:
Sorry i forgot to post my expression though it the same as yours
=Avg([Total Miles] / [Total Ltrs]). Though, like i say, it throws up the
parameter dialog box asking for a value for [Total Miles] then [Total Ltrs]
or LGP if i put
=Avg([LPG]). Both fields are derived from calculated fields in my query but
each have the record source from the query so dont undertand why it asking
for values when they there. I have created a footer but i dont get an #error
or #Name just a blank text box. Can you help me figure it out Dale???.
Incidently, this not the 1st time you help me. I needed a parameter date
query to find conflicting holiday requests by staff few months ago and you
got it spot on. I Thanked you but got no reply. But Thanx again. It actually
pretty good!!
 
Back
Top