Conditional AVG in report footing

  • Thread starter Thread starter pyrahna
  • Start date Start date
P

pyrahna

I am trying to do a conditional avg in my report footing. I would
like to avg values that are on the same row as an item between 7000
and 9000. for instance

6000 2
7500 3
8000 4
8500 5
9500 6
the answer would be 4
I have tried both of the following to no avail
=IIf(([RPM]>7000) And ([RPM]<9000),Avg([rpm]),0)
and
SUM(iif(([RPM]>7000) And ([RPM]<9000),[RPM],0))/SUM(iif(([RPM]>7000)
And ([RPM]<9000),1,0))
neither of which have worked.

any ideas would be appreciated.
 
What is the name of the second field?

You did not include it in your compatation but I thought it was the field to
be averaged.
 
What is the name of the second field?

You did not include it in your compatation but I thought it was the field to
be averaged.
--
KARL DEWEY
Build a little - Test a little

pyrahna said:
I am trying to do a conditional avg in my report footing. I would
like to avg values that are on the same row as an item between 7000
and 9000. for instance
6000 2
7500 3
8000 4
8500 5
9500 6
the answer would be 4
I have tried both of the following to no avail
=IIf(([RPM]>7000) And ([RPM]<9000),Avg([rpm]),0)
and
SUM(iif(([RPM]>7000) And ([RPM]<9000),[RPM],0))/SUM(iif(([RPM]>7000)
And ([RPM]<9000),1,0))
neither of which have worked.
any ideas would be appreciated.

Sorry, the first field i am avg is the RPM field, the next field would
work like this(if this code actually worked like i would like it to)
=IIf(([RPM]>7000) And ([RPM]<9000),Avg([Power]),0)

or

SUM(iif(( said:
And ([RPM]<9000),1,0))
 
Try this --
SELECT Avg(YourTable.RPM) AS AvgOfRPM, Avg(YourTable.Power) AS AvgOfPower
FROM YourTable
WHERE (((YourTable.RPM) Between 7000 And 9000));

--
KARL DEWEY
Build a little - Test a little


pyrahna said:
What is the name of the second field?

You did not include it in your compatation but I thought it was the field to
be averaged.
--
KARL DEWEY
Build a little - Test a little

pyrahna said:
I am trying to do a conditional avg in my report footing. I would
like to avg values that are on the same row as an item between 7000
and 9000. for instance
6000 2
7500 3
8000 4
8500 5
9500 6
the answer would be 4
I have tried both of the following to no avail
=IIf(([RPM]>7000) And ([RPM]<9000),Avg([rpm]),0)
and
SUM(iif(([RPM]>7000) And ([RPM]<9000),[RPM],0))/SUM(iif(([RPM]>7000)
And ([RPM]<9000),1,0))
neither of which have worked.
any ideas would be appreciated.

Sorry, the first field i am avg is the RPM field, the next field would
work like this(if this code actually worked like i would like it to)
=IIf(([RPM]>7000) And ([RPM]<9000),Avg([Power]),0)

or

SUM(iif(( said:
And ([RPM]<9000),1,0))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top