You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Use AVERAGEIF with "OR" expression?

I'm trying to use AVERAGEIF to average all cells B26:W26 if cells B29:W29 contain either "Friday", "Saturday", or "Sunday". I can't figure out how to do this and I've spent the past thirty minutes searching discussions and google so I apologize if the answer is out there and I've just been searching for it the wrong way.


I've tried:

AVERAGEIFS(LIFE LOG::B26:W26,LIFE LOG::B29:W29,"=Friday",LIFE LOG::B29:W29,"=Saturday",LIFE LOG::B29:W29,"=Sunday")

... but I realized that that only includes a cell in the average if ALL those conditions are met for each cell compared, which is of course impossible.


I've also tried:

AVERAGEIF(LIFE LOG::B29:W29,"=Friday OR =Saturday OR =Sunday",LIFE LOG::B26:W26)

... but that doesn't work.


I've also tried using the OR(...) function in the condition argument but that only works with boolean values, not strings.


Is there a way to achieve what I'm hoping to achieve (ideally, without creating a new row with number values or checkboxes to reflect whether whether the column is a "Friday", "Saturday", or "Sunday" column or something like that -- I'm trying to avoid further complexity as this table is fairly large and complex already)?


Thanks for any help with this!

MacBook Pro with Retina display, macOS Sierra (10.12.2), 2016 MacBook Pro 15" with touch bar

Posted on Oct 9, 2017 10:12 AM

Reply
9 replies

Oct 9, 2017 11:32 AM in response to andronerf

If I understand you correctly, you can try something like this:


User uploaded file


=IF(OR(COUNTIF(B29:W29,"Friday")>0,COUNTIF(B29:W29,"Saturday")>0,COUNTIF(B29:W29 ,"Sunday")>0),AVERAGE(,B26:W26),"")



If you have a large and complex table such as one might see in Excel, highly recommend you consider arranging things "Numbers-style." Break up your work into smaller, self-contained tables. See the templates at File > New for effective organization of Numbers documents.


SG

Oct 9, 2017 6:09 PM in response to andronerf

Hi andronerf,


Does this work:

(I've deliberately chosen identical value for every day that is to be included, and a different identical value for each day that is not to be included. This makes the result immediately identifiable as correct or incorrect.)

User uploaded file


Here's the same table with random values in the range 0-8 placed in column B.

The AVERAGEIF formula, shown below the table, is the same as used above.

Column E results are NOT used by the formula in D2. This column does show the values that have been included in the average calculation.

User uploaded file

Regards,

Barry

Oct 9, 2017 1:02 PM in response to SGIII

Thanks for replying so quickly, SG. Unfortunately that doesn’t solve my issue but I may not have been totally clear explaining it.


In the solution you offer, if a single “Friday”, “Saturday” or “Sunday” is found in row 29, the AVERAGE function would average all cells in row 26, even those without corresponding values in row 29 of “Friday”, ”Saturday” or “Sunday” (e.g., even those that have “Monday” or “Tuesday” or any other value) and that’s unfortunately not what I’m trying to do.


My table is a “life log”, so each column is a day of the year and each row is something I’m tracking (e.g., hours spent exercising, hours worked, alcoholic beverages consumed, etc.). I have an autopopulated cell in each column for which day of the week it is, and in a separate graph, I am trying to average certain values for certain types of days of the week (hence “Friday”/“Saturday”/“Sunday”). I need an AVERAGEIF(...) or AVERAGEIFS(...) that can help me achieve that and thereby give me an accurate average for, say, number of alcoholic beverages on those days, or hours worked on those days, etc.


I don’t think using OR(...) within the AVERAGEIF function will work due to limitations with booleans and I’m trying to avoid overly complex solutions such as the ones mentioned in the first post, or even another option like averaging Fridays, Saturdays and Sunday separately from each other in additional placeholder fields and then averaging those three results together. So I’m hoping I can achieve the result I’m looking for with one function in a cell, without adding more rows/cells/tables. Hopefully that’s not impossible in Numbers.


Thanks again for any help with this issue!

Oct 9, 2017 5:35 PM in response to Wayne Contello

Thanks Wayne, I could do that and get a sum of the averages, but even if I averaged those averages by dividing that sum by three, that wouldn’t be an exactly accurate average — e.g., imagine that my table has many fewer Sundays than Fridays or Saturdays - say there’s only one ”Sunday” and the value in the row I’m concerned with for that Sunday column is “300” but all the Friday and Saturday columns, of which there are thousands in this extreme example, have “0” in every cell in that row, in this example, the proposed solution would create an average of “100” [300 divided by 3] even though the actual average is near zero [300 divided by, say, 3,000]).


That’s an extreme example and in my case, your solution would be closer to the right answer but would still be wrong and I’m looking for exact numbers. Is there any way to pull this off?


Thanks again!

Use AVERAGEIF with "OR" expression?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.