Need help with Davg

ARW17

Board Regular
Joined
Oct 31, 2016
Messages
109
What I need to do is average [ratio] by [day] if [Use?] = "y".

I've read a bunch of Davg posts, but I can't get it to work with my data. Any help is appreciated!

My Data:

WorkDateDayRatioUse?
10/31/16MONDAY6.67%n
11/7/16MONDAY6.22%y
11/14/16MONDAY6.19%n
11/21/16MONDAY6.10%y
11/28/16MONDAY7.28%Y
10/25/16TUESDAY6.35%n
11/1/16TUESDAY5.81%y
11/8/16TUESDAY6.25%y
11/1/16TUESDAY6.22%y
11/15/16TUESDAY6.59%y
10/19/16WEDNESDAY6.27%n
10/26/16WEDNESDAY6.30%y
11/2/16WEDNESDAY6.30%y
11/9/16WEDNESDAY6.61%y
11/16/16WEDNESDAY6.13%y
10/20/16THURSDAY6.16%n
10/27/16THURSDAY6.16%y
11/3/16THURSDAY6.03%y
11/10/16THURSDAY6.20%y
11/17/16THURSDAY6.60%Y
10/21/16FRIDAY6.79%y
10/28/16FRIDAY5.35%y
11/4/16FRIDAY6.40%y
11/11/16FRIDAY6.77%y
11/18/16FRIDAY7.49%Y

<colgroup><col><col span="2"><col></colgroup><tbody>
</tbody>

I want my final results to be:
Monday 6.53%
Tuesday 6.22%
Wednesday 6.33%
Thursday 6.25%
Friday 6.56%
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I would use an Aggregate Query instead, i.e.
Code:
SELECT Day, Avg(Ratio) AS AvgOfRatio
FROM TableName
WHERE [Use?]="y"
GROUP BY Day;
 
Upvote 0
I would use an Aggregate Query instead, i.e.
Code:
SELECT Day, Avg(Ratio) AS AvgOfRatio
FROM TableName
WHERE [Use?]="y"
GROUP BY Day;

Thanks! You led me down another road, which got me to the right answer. I haven't written any VBA in Access yet. Where would I put the code you provided?

The solution I used was:
Field: Day Ratio Use?
Total: GrpBy Avg GrpBy
Criteria: "" "" ="y"
 
Upvote 0
It is not VBA - it is SQL. When you create a query, you are using Query Builder. That is just a GUI Interface that builds SQL code for you behind the scenes.
If you create a new query, and change to SQL View, you can copy and paste the SQL code there and run the query.

But you can easily build this using the Query Builder by doing the following:
1. Add the Day, Ratio, and Use? fields to your query.
2. Add "y" to the Criteria row of the Use? field
3. Click on the Totals button (looks like a Sigma)
4. On the new Totals row that gets added under each field, change the value under the Ratio field from "Group By" to "Avg"
5. On the new Totals row that gets added under each field, change the value under the Use? field from "Group By" to "Where"
6. View your results

Aggregate queries are very useful and powerful. I would highly recommend brushing up on them. You can do a Google Search or check out YouTube for some tutorials.
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,695
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top