AVERAGE IF (maybe OR?) (probably a very simple solution)

cockneyjosh

New Member
Joined
May 13, 2014
Messages
6
All I want to do is to calculate an average from a table that takes account of two pieces of criteria, but instead of needing both pieces of criteria I just need one or the other. In this case it is the average value of contracts from two out of the 5 companies in the study. I have tried AVERAGEIF(D4:15,"LUMS"or"WBS", F4:F15) which I know is wrong but I can't figure out how else to do it. I am sure the solution is simple but I can't find it myself
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You basically got it:

=AVERAGEIF(D4:15,OR("LUMS","WBS"), F4:F15)
 
Last edited:
Upvote 0
All I want to do is to calculate an average from a table that takes account of two pieces of criteria, but instead of needing both pieces of criteria I just need one or the other. [....] I have tried AVERAGEIF(D4:15,"LUMS"or"WBS", F4:F15) which I know is wrong

Array-enter the following formula (press ctrl+shift+Enter instead of just Enter):

=AVERAGE(IF(D4:D15={"LUMS","WBS"},F4:F15))
 
Upvote 0
Array-enter the following formula (press ctrl+shift+Enter instead of just Enter):
=AVERAGE(IF(D4:D15={"LUMS","WBS"},F4:F15))

Out of interest what is the reason for having to use the Array bit?

That's an astute question.

"Obviously", IF(D4:D15={"LUMS","WBS"},F4:F15) returns an array of values, and AVERAGE accepts an array of values. In fact, if we execute the following in VBA:
Code:
Evaluate("AVERAGE(IF(D4:D15={""LUMS"",""WBS""},F4:F15))")
Excel knows to treat that as an array formula with no special indication.

However, when formulas of that form are entered into a cell, I believe there is a potential semantic ambiguity, not so much with that particular formula, AFAIK, but with others. We rely on that ambiguity when we use a named range in a table, for example.

That is my rationalization. I cannot say with impunity it is the correct explanation.
 
Upvote 0

Forum statistics

Threads
1,216,019
Messages
6,128,311
Members
449,439
Latest member
laurenwydo

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