Help with Averaging Based on Cell Conditions

cionnaith

Board Regular
Joined
Mar 9, 2010
Messages
52
Hello folks!

I am trying to calculate averages across an array of cells for one of six conditions in those cells.

I have five cells (i.e. G11:G15) where each cell can have one of six conditions (e.g. morning, afternoon, ... ) that are being read from another worksheet. In another column I have percentages associated with those five cells (i.e. I11:I15). In a third array of cells (i.e. I19:I24) I need to calculate the average for each of the conditions as they are present across those five cells. For example,

G I
11 morning 11 50%
12 morning 12 75%
13 afternoon 13 100%
14 afternoon 14 50%
15

I
19 average of all of the percents in I when G contains "morning"
20 average of all of the percents in I when G contains "afternoon"
21
22
23
24

etc..

The only other thing I need is to have the calculations in the I19:I24 cells return a blank cell if there are no entries in the others.

I hope this makes sense. Thanks so much in advance.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello folks!

I am trying to calculate averages across an array of cells for one of six conditions in those cells.

I have five cells (i.e. G11:G15) where each cell can have one of six conditions (e.g. morning, afternoon, ... ) that are being read from another worksheet. In another column I have percentages associated with those five cells (i.e. I11:I15). In a third array of cells (i.e. I19:I24) I need to calculate the average for each of the conditions as they are present across those five cells. For example,

G I
11 morning 11 50%
12 morning 12 75%
13 afternoon 13 100%
14 afternoon 14 50%
15

I
19 average of all of the percents in I when G contains "morning"
20 average of all of the percents in I when G contains "afternoon"
21
22
23
24

etc..

The only other thing I need is to have the calculations in the I19:I24 cells return a blank cell if there are no entries in the others.

I hope this makes sense. Thanks so much in advance.
Are you wanting to average H11:H14? If so:

J19: morning
J20: afternoon

I19:
Code:
=IF(COUNTIF($G$11:$G$14,J19),
    SUMIF($G$11:$G$14,J19,$H$11:$H$14)/COUNTIF($G$11:$G$14,J19),
    "")

On Excel 2007 or later:

Code:
=IF(COUNTIF($G$11:$G$14,J19),
    AVERAGEIF($G$11:$G$14,J19,$H$11:$H$14),
    "")
 
Upvote 0
Are you wanting to average H11:H14? If so:

J19: morning
J20: afternoon

I19:
Code:
=IF(COUNTIF($G$11:$G$14,J19),
    SUMIF($G$11:$G$14,J19,$H$11:$H$14)/COUNTIF($G$11:$G$14,J19),
    "")

On Excel 2007 or later:

Code:
=IF(COUNTIF($G$11:$G$14,J19),
    AVERAGEIF($G$11:$G$14,J19,$H$11:$H$14),
    "")

No, H is an empty column. Only need to average across I's based on the conditions in G's
 
Upvote 0
Hello folks!

I am trying to calculate averages across an array of cells for one of six conditions in those cells.

I have five cells (i.e. G11:G15) where each cell can have one of six conditions (e.g. morning, afternoon, ... ) that are being read from another worksheet. In another column I have percentages associated with those five cells (i.e. I11:I15). In a third array of cells (i.e. I19:I24) I need to calculate the average for each of the conditions as they are present across those five cells. For example,

G I
11 morning 11 50%
12 morning 12 75%
13 afternoon 13 100%
14 afternoon 14 50%
15

I
19 average of all of the percents in I when G contains "morning"
20 average of all of the percents in I when G contains "afternoon"
21
22
23
24

etc..

The only other thing I need is to have the calculations in the I19:I24 cells return a blank cell if there are no entries in the others.

I hope this makes sense. Thanks so much in advance.
What version of Excel are you using?
 
Upvote 0
In 2007, you can use
Code:
=AVERAGEIFS(I11:I15,G11:G15,"morning")

lenze

Thanks...that works great. The only thing I need to do is make it so that it returns a blank cell instead of the DIV0 thing if cells being averaged are empty (for instance, there are no percentages in I for "morning" because there are no "morning"s in that particular array. Do I just add ,"") to the end?

Thanks again!
 
Upvote 0
Thanks...that works great. The only thing I need to do is make it so that it returns a blank cell instead of the DIV0 thing if cells being averaged are empty (for instance, there are no percentages in I for "morning" because there are no "morning"s in that particular array. Do I just add ,"") to the end?

Thanks again!
Try it like this...

=IFERROR(AVERAGEIFS(I11:I15,G11:G15,"morning"),"")
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,896
Members
452,948
Latest member
Dupuhini

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