+ Reply to Thread
Results 1 to 18 of 18

AVERAGE with OR function

  1. #1
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    AVERAGE with OR function

    I want to create a formula that says, "if a cell in column D has the phrase "triple net", or if a cell in column D has the word "base" then take the average of the corresponding cells in column M." This is the formula I have come up with but it isn't working... any suggestions? Do I need the OR function?

    =IF(OR($D:$D="*triple net",$D:$D="*base*"),AVERAGE($M:$M),"0")

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,966

    Re: AVERAGE with OR function

    Try this:
    =AVERAGEIF(D:D,{"*triple net";"*base*"},M:M)
    Last edited by Glenn Kennedy; 08-02-2016 at 12:46 PM. Reason: Forgot the * after base
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    I think you're going to have to do the Sum/Count

    =SUM(SUMIF($D:$D,{*triple net","*base*"},$M:$M))/SUM(COUNTIF($D:$D,{*triple net","*base*"}))

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,966

    Re: AVERAGE with OR function

    It SEEMED to work Ok for me. BtW, Jonmo - you forgot the " before each of the *triplenets...

  5. #5
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    Thanks guys, I think I've got it down

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    Good catch on the missing ", thanks

    Should be
    =SUM(SUMIF($D:$D,{"*triple net","*base*"},$M:$M))/SUM(COUNTIF($D:$D,{"*triple net","*base*"}))


    =AVERAGEIF(D:D,{"*triple net";"*base*"},M:M)
    This is only going to include the triple net in the average.

    This kind of {or variable} structure works for summing and counting
    SUM(SUMIF($D:$D,{*triple net","*base*"},$M:$M))

    But you can't use that for an average, as in
    AVERAGE(SUMIF($D:$D,{*triple net","*base*"},$M:$M))

  7. #7
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    However, what is the use of the "curly" brackets and the semicolon? I don't think I've ever used those in Excel before....

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,966

    Re: AVERAGE with OR function

    Jonmo. You're right: 100,000 apologies.. NDmad. use his formula.

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    The {brackets} create a 'Constant Array'
    The semicolon is just a list seperator, can also be a comma.

    Since Average = Sum/Count
    We need to get the SUM of values in M where D = x OR y - this is the sumif part
    Then we need to get the COUNT of times where D = x OR y - this is the countif part

    Here's what happens, taking just half of my formula, the sumif part (the countif part works exactly the same, just a count instead of sum)
    SUM(SUMIF($D:$D,{"*triple net","*base*"},$M:$M))
    The {constant array} essentially makes excel perform 2 versions of the SUMIF.
    1 using "*triple net"
    the other using "*base*"
    It's as if you did this
    =SUMIF($D:$D,"*triple net",$M:$M)+SUMIF($D:$D,"*base*",$M:$M)

  10. #10
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    Thank you. What if I want to add one more condition that I don't want it to average any numbers in column M that equal 0?

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    We'd have to add that criteria to the count, and use countifS

    =SUM(SUMIF($D:$D,{"*triple net","*base*"},$M:$M))/SUM(COUNTIFS($D:$D,{"*triple net","*base*"},$M:$M,"<>0"))

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: AVERAGE with OR function

    Here's another one...

    Data Range
    A
    B
    C
    D
    M
    1
    ------
    ------
    ------
    ------
    ------
    2
    3
    43
    blah
    24
    4
    triple net bet
    10
    5
    blah
    4
    6
    X triple net
    31
    7
    data
    28
    8
    blah
    92
    9
    xxx
    51
    10
    plump base
    88
    11


    This array formula** entered in A3:

    =AVERAGE(IF(ISNUMBER(SEARCH({"Triple net","Base"},D3:D10)),M3:M10))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    You should avoid using entire columns as range references in array formulas.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  13. #13
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    Thank you everyone. I have one final question that I hope isn't too convoluted....

    The formula I ended up using was the one Jonmo provided.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I used this formula to find an expense rate from a set of data. The excel doc I was working in had 7 different sheets with similar sets of data (i.e., same column headings, different numbers within the columns).

    I then duplicated Jonmo's formula across all 7 different sheets to find the expense rate for each sheet.

    On the final sheet, I want to be able to find the average of these 7 different expense rates. As a general rule of thumb, I know that it isn't correct to just take the averages and divide by the number of averages there are. So is there a way to modify Jonmo's formula (which is the same across all sheets) to find the average of the expense rates of all four sheets?

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    You're right, you can't really do an average of averages...

    What you could do is put individual SUMs for each sheet, and individual COUNTs for each sheet.
    The you can SUM all the sums, and divide by the sum of all the counts..

    So instead of this in each individual sheet
    =SUM(SUMIF($D:$D,{"*triple net","*base*"},$M:$M))/SUM(COUNTIFS($D:$D,{"*triple net","*base*"},$M:$M,"<>0"))

    Designate 3 cells in each sheet, one for the sum, one for the count, and one for the average..
    Say
    J2: =SUM(SUMIF($D:$D,{"*triple net","*base*"},$M:$M))
    K2: =SUM(COUNTIFS($D:$D,{"*triple net","*base*"},$M:$M,"<>0"))
    L2: =J2/K2

    Then on your summary sheet, you can do
    A1: =SUM(Sheet1!J2,Sheet2!J2,Sheet3!J3,etc)
    B1: =SUM(Sheet1!K2,Sheet2!K2,Sheet3!K3,etc)
    C1: =A1/B1

  15. #15
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    Awesome thanks!

    Lastly, there are some worksheets where cells J2 and K2 have zeroes in them because the data that they pulled from did not match up with the criteria of the formula within that cell (which is okay for what I'm doing on my end...almost expected). However, this creates a problem when finding the value in L2 because I get a "#DIV/0!" error message. Because of this error message, it makes it difficult to find the values for my summary sheet.

    Is there a way where I can modify the formulas in cells A1, B1, C1 on the summary sheet to just ignore the sheets that have that "#DIV/0!" error message? I only want to be finding the averages for the sheets that actually have values in cells J2, K2, and L2.

    Thanks!

  16. #16
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    I would add IFERROR to the formula in L2 on each sheet..

    L2: =IFERROR(J2/K2,0)

  17. #17
    Registered User
    Join Date
    06-20-2016
    Location
    Wisconsin, USA
    MS-Off Ver
    365 ProPlus
    Posts
    44

    Re: AVERAGE with OR function

    Thank you Jonmo...YUGE help

  18. #18
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AVERAGE with OR function

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Moving average/average function/adjustable length
    By Lv27 in forum Excel General
    Replies: 3
    Last Post: 08-16-2012, 09:43 AM
  2. Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Don Guillett in forum Excel Formulas & Functions
    Replies: 78
    Last Post: 09-06-2005, 07:05 PM
  3. [SOLVED] Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Don Guillett in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 09-06-2005, 11:05 AM
  4. [SOLVED] Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. [SOLVED] Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Don Guillett in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 09-06-2005, 06:05 AM
  6. Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  8. Error Handling #N/A with AVERAGE Function - Average of values in Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-31-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1