Excel averageifs with or function
Asked Answered
T

5

5

I am using the averageifs function, and have one column where I need to calculate the average if either of the criteria are true.

I have tried using the OR function, and tried the curly brackets, but both give me errors.

=AVERAGEIFS(N1:N612,I1:I612,{"FL","IF"})

There are more ranges, but the coding for those is fine.

To be clear, I want to return an average if column "I" contains (specifically) the letters FL, OR the letters IF. Any other letters should mean that entry is not averaged.

TIA!

Tahiti answered 27/5, 2015 at 16:37 Comment(0)
S
10

AVERAGEIFS extra criteria is a boolean AND operator, it can't perform OR operations. But since your columns do not change we can somewhat implement this ourselves:

Here is a simple way using an array formula (entered with ctrl + shift + enter):

=AVERAGE(IF((I1:I612="IF")+(I1:I612="FL"),N1:N612))

Or if you don't like using array formulas you basically do this manually using SUMPRODUCT and COUNTIF:

=SUMPRODUCT((I1:I612="IF")*(N1:N612)+(I1:I612="FL")*(N1:N612))/(COUNTIF(I1:I612,"IF")+COUNTIF(I1:I612,"FL"))
Shelia answered 27/5, 2015 at 17:1 Comment(0)
U
6

Chancea has given some good techniques I will list one more that avoids array formulas as many will find it easier to read avoiding the sumproduct.

=(SUMIF(I1:I612,"FL",N1:N612)+SUMIF(I1:I612,"IF",N1:N612))/(COUNTIF(I1:I612,"FL")+COUNTIF(I1:I612,"IF"))
Uppermost answered 27/5, 2015 at 18:2 Comment(1)
Old thread but this answer to date is still the best for readability, thanks.Dufresne
E
2

Do not think Excel has this feature, but in Google Sheets, I've been using the below to achieve similar results

=average(filter($A:$A,($C:$C=$E$6)+($C:$C=$E$7)))

giving me an average of the values in A:A where C:C matches the value in either E6 or E7

unlike an ifs / sumifs etc., the filter uses =, not a comma, thus $C:$C=$E$6 is used, not $C:$C,$E$6

Mathematical symbols are just entered ( so <> rather than "<>"& )

Euphonious answered 6/2, 2018 at 14:45 Comment(1)
If you're using Google Sheets, this seems a lot cleaner than the other solutions and works really well.Careerist
D
0

Another way to solve this would be to create an additional column (let's call it column J) that returns TRUE if column I contains either "FL" or "IF":

J1 = IF(OR(I1="FL",I1="IF"),TRUE,FALSE)

Then you can reference that column in your AVERAGEIFS formula instead:

=AVERAGEIFS(N1:N612,J1:JI612,TRUE)
Dean answered 13/5, 2022 at 23:6 Comment(0)
V
0

A solution to your question is:

=AVERAGE(Maxifs(N1:N612,I1:I612,{"FL";"IF"}))

Vladikavkaz answered 20/11, 2022 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.