+ Reply to Thread
Results 1 to 13 of 13

AVERAGEIF using multiple string compares

  1. #1
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    AVERAGEIF using multiple string compares

    Hello All!
    I have an AVERAGEIF formula that has multiple wildcard string compare conditions in the same column. It doesn't appear to be searching properly and I believe the problem is, it's only looking at one condition. Here is that I have below:

    =AVERAGEIF(MBR!A:A,{"*Civil*","*Shim*","*Power*","*GO&G*"},MBR!H:H)

    Any advice would be greatly appreciated please!

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Try this:

    =AVERAGE(IF(ISNUMBER(SEARCH({"Civil","Shim","Power","GO&G"},MBR!A$2:A$1000)),MBR!H$2:H$1000)) Ctrl Shift Enter

    Adjust the ranges to suit your need. Just don't use whole column references.
    Last edited by 63falcondude; 04-19-2018 at 01:15 PM. Reason: Adjusted for wildcards

  3. #3
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    Re: AVERAGEIF using multiple string compares

    Hrrmm... I doesn't appear to be grabbing all of the fields. I think I failed to explain properly, the string criteria need to be "OR" instead of "AND". If any of those strings show in column MBR!A$2:A$1000 then they need to be included.

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Yes, that is what the formula from post #2 should be doing.

    If you attach a small representative sample of your data along with the desired result (which you can enter manually), I'll have a look and see what is going on.

    Also, make sure that you are entering the formula using Ctrl+Shift+Enter and not just Enter like you do with normal formulas.

    To upload an Excel workbook, follow these steps:
    1) Click on "Go Advanced"
    2) Click on "Manage Attachments"
    3) Click on "Choose File"
    4) Choose your file and click on "Open"
    5) Click on "Upload"
    6) Click on "Close this window"

  5. #5
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    Re: AVERAGEIF using multiple string compares

    Ok, that's fantastic!! Thank you again for all your help!!! The formula in question in on the "EIC" tabl and it is the E9 cell.
    Attached Files Attached Files

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Looks like there are blank cells in column H. Should those be ignored or treated as zero?

    If blanks should be ignored, simply add this part (in red):

    =AVERAGE(IF(ISNUMBER(SEARCH({"Civil","Shim","Power","GO&G"},MBR!A$2:A$1000))*(MBR!H$2:H$1000<>""),MBR!H$2:H$1000)) Ctrl Shift Enter

    I get 94.85
    Last edited by 63falcondude; 04-19-2018 at 03:34 PM.

  7. #7
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    Re: AVERAGEIF using multiple string compares

    This works great, thank you so much!! One last question for you please. If I would like to add another criteria to only pull for a particular month list on another tab, would I just add it like this to the formula?

    =AVERAGE(IF(ISNUMBER(SEARCH({"Civil","Shim","Power","GO&G"},MBR!A$2:A$1000))*(MBR!H$2:H$1000<>"")*(MBR!B:B,"*"&'stoplight chart_CS '!L1&"*"),MBR!H$2:H$1000))

  8. #8
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    Re: AVERAGEIF using multiple string compares

    ok... well I tried that and it did not work The intent of this added constraint is to make it so that all the user has to do is change the month on the first tab, and the rest of the monthly formulas automatically change. Your help would be greatly appreciated!

  9. #9
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    No, you can't use wildcards like that in an array formula. Also, B:B should be B$2:B$1000.

    Simply correcting the syntax would look like this:

    =AVERAGE(IF(ISNUMBER(SEARCH({"Civil","Shim","Power","GO&G"},MBR!A$2:A$1000))*(MBR!H$2:H$1000<>"")*(ISNUMBER(SEARCH('stoplight chart_CS '!L1,MBR!B$2:B$1000))),MBR!H$2:H$1000)) Ctrl Shift Enter

    If that doesn't do what you are expecting, we will need to see a small sample of the data and expected results.

  10. #10
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Looking at the "sample" sheet from post #5, column B of the MBR sheet is the same as L1 of the stoplight_chart_CS sheet.

    Why do you want to use a wildcard for that?

    You should be able to simply use this:

    =AVERAGE(IF(ISNUMBER(SEARCH({"Civil","Shim","Power","GO&G"},MBR!A$2:A$1000))*(MBR!H$2:H$1000<>"")*('stoplight chart_CS '!L1=MBR!B$2:B$1000),MBR!H$2:H$1000)) Ctrl Shift Enter
    Last edited by 63falcondude; 04-20-2018 at 09:38 AM.

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Better yet, this can be done without an array formula.

    Since average is sum/count, you can use this:

    =SUM(SUMIFS(MBR!H:H,MBR!A:A,{"*Civil*","*Shim*","*Power*","*GO&G*"},MBR!H:H,"<>",MBR!B:B,'stoplight chart_CS '!L1))/SUM(COUNTIFS(MBR!A:A,{"*Civil*","*Shim*","*Power*","*GO&G*"},MBR!H:H,"<>",MBR!B:B,'stoplight chart_CS '!L1))

  12. #12
    Registered User
    Join Date
    03-19-2018
    Location
    Houston, Texas
    MS-Off Ver
    2013
    Posts
    8

    Re: AVERAGEIF using multiple string compares

    I guess I was reaching waaaaaay back to my old coding days when I used a lot of wildcards searches in queries. You solution is clearly much more elegant that my hack job haha. Sincerely, thank you so much for your help!! I've got a lot to learn :p

  13. #13
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: AVERAGEIF using multiple string compares

    Happy to help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Formula for Multiple Range Compares in Excel
    By RaMubara in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-27-2017, 03:01 AM
  2. [SOLVED] AVERAGEIF Multiple Columns Multiple occurrences
    By jeroenft in forum Excel General
    Replies: 4
    Last Post: 02-03-2015, 04:58 PM
  3. [SOLVED] AverageIF using multiple criteria in different columns in multiple worksheets
    By trubertiam in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-03-2014, 09:28 PM
  4. IF Statement that compares multiple cells and gives me the lowest number
    By williamfrus in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-07-2012, 07:37 PM
  5. Macro that compares balance totals in multiple worsheets and calculates differences?
    By tomqueens in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 12:57 PM
  6. AVERAGEIF with String Parsing
    By sdoah206 in forum Excel General
    Replies: 5
    Last Post: 07-15-2011, 12:58 PM
  7. String Compares
    By bstubbs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2009, 08:13 AM

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