Averageifs formula - can you search for two different criteria in one criteria range

CLARE83

New Member
Joined
Jun 11, 2014
Messages
28
Hi,

I am working on spreadsheet in which I have a column of data (combined score) for which I need to find the average off if they match 2 different criteria's (status - A and P)in a different column.

Below is an example of the data.

Can anyone advise of the formula I keep hitting a brick wall!!!

Thanks in advance


MonthSTATUSCombined Sccore
JANN31
FEB31
MAR25
APR27
MAYA27
JUNP11
JULYP23
AUG25
SEP27
OCT25

<tbody>
</tbody>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Welcome to the board. I couldn't get SUMIFS to work, but these two seem to:
Code:
=SUMIF($B$1:$B$10,"A",$C$1:$C$10)+SUMIF($B$1:$B$10,"P",$C$1:$C$10)
Code:
=SUMPRODUCT($C$1:$C$10,--(($B$1:$B$10="A")+($B$1:$B$10="P")))
 
Upvote 0
Thanks Jack, however is there a formula that will give me the average score of the data for only A & P? The two provided formulas only gives a total.

Thanks again
 
Upvote 0
Thanks Jack, however is there a formula that will give me the average score of the data for only A & P? The two provided formulas only gives a total.

Thanks again

Try one of:

=SUM(SUMIFS(C2:C11,B2:B11,{"A","P"}))/MAX(1,SUM(COUNTIFS(B2:B11,{"A","P"})))

=IFERROR(SUM(SUMIFS(C2:C11,B2:B11,{"A","P"}))/SUM(COUNTIFS(B2:B11,{"A","P"})),"")
 
Upvote 0
CLARE83,

Welcome to MrExcel.

I don't think you will get AVERAGEIFS working with OR criteria.

Maybe try this....

Excel 2007
ABCD
1MonthSTATUSCombined SccoreAverage
2JANN3120.33333333
3FEB31
4MAR25
5APR27
6MAYA27
7JUNP11
8JULYP23
9AUG25
10SEP27
11OCT25
Sheet48
Cell Formulas
RangeFormula
D2=IFERROR(SUMPRODUCT(((B2:B11="A")+(B2:B11="P"))*C2:C11)/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")

Hope that helps.
 
Last edited:
Upvote 0
Thanks both, they all work. Can you just break down the formulas for me so I can have a better understanding of how it works?

Thanks

Clare
 
Upvote 0
Thanks both, they all work. Can you just break down the formulas for me so I can have a better understanding of how it works?

Thanks

Clare

Tony proposes a heavy formula (performancewise)...:ROFLMAO:

=SUM(SUMIFS(C2:C11,B2:B11,{"A","P"}))/MAX(1,SUM(COUNTIFS(B2:B11,{"A","P"})))

Supposing that you know how SumIfs and CountIfs, we can be bref. Both SumIfs and CountIfs give one result for each criteria in {"A","P"}. Surrounding Sum totals those results...

So we move from:

SUM/COUNT

to

SUMIFS/COUNTIFS

to

SUM(SUMIFS)/SUM(COUNTIFS)

that is, from an unconditional average to a conditional average.
 
Upvote 0
Tony proposes a heavy formula (performancewise)...:ROFLMAO:

'Never mind the quality...... feel the weight!!' is my motto. :p;)

Clare, here is a bit of an explanation of my formula. Do take care when lifting!!

IFERROR wrapper should be self-explanatory.
Google SUMPRODUCT if you are not aware of what it does but essentially, it sums the products of one or more arrays.
You can highlight any element of the formula, in the formula bar, and press F9 to evaluate that element as I have done to create the below.
Hopefully, it illustrates how each element of the formula is resolved. Firstly the array elements then the products and the sums.
Within the Sumproduct, any True False values become 1's or 0's when operated on by a math operator. * equates to AND and + equates to OR

Cell Formulas
RangeFormula
D2=IFERROR(SUMPRODUCT(((B2:B11="A")+(B2:B11="P"))*C2:C11)/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D3=IFERROR(SUMPRODUCT(({FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE}+(B2:B11="P"))*C2:C11)/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D4=IFERROR(SUMPRODUCT(((B2:B11="A")+{FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;TRUE;FALSE;FALSE;FALSE})*C2:C11)/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D5=IFERROR(SUMPRODUCT(({0;0;0;0;1;1;1;0;0;0})*C2:C11)/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D6=IFERROR(SUMPRODUCT(((B2:B11="A")+(B2:B11="P"))*{31;31;25;27;27;11;23;25;27;25})/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D7=IFERROR(SUMPRODUCT({0;0;0;0;27;11;23;0;0;0})/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D8=IFERROR(61/SUMPRODUCT((B2:B11="A")+(B2:B11="P")),"")
D9=IFERROR(SUMPRODUCT(((B2:B11="A")+(B2:B11="P"))*C2:C11)/3,"")
D10=IFERROR(61/3,"")


BTW I do charge by the kilogram!!
 
Last edited:
Upvote 0
Thanks,

Do you know if the sum/sumif formula's will work if they are on a different marksheet, the formula im using now comes back #N/A

The formula is -

=SUMPRODUCT(((Sheet1!F2:F237="A")+(Sheet1!F2:F237="P")+(Sheet1!F2:F23="S")*Sheet1!P2:P237/SUMPRODUCT((Sheet1!F2:F237="A")+(Sheet1!F2:F237="P")+(Sheet1!F2:F237="S"))))

F2:F237 IS STATUS AND P2:P237 IS COMBINED SCORE

Thanks

Clare
 
Upvote 0
Hi :)

Two other formulas ... for a wider choice ;)

=SUMPRODUCT(SUMIF($B$2:$B$11,{"A";"P"},$C$2:$C$11))/SUMPRODUCT(--($B$2:$B$11={"A";"P"}))

and ENTER

or

=AVERAGE(INDEX(IF($B$2:$B$11<>"A",IF($B$2:$B$11="P",$C$2:$C$11),$C$2:$C$11),0))

and CTRL+SHIFT+ENTER

Regards
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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