+ Reply to Thread
Results 1 to 10 of 10

AVERAGEIF - single criterion in multiple columns?

  1. #1
    Registered User
    Join Date
    11-16-2016
    Location
    Norway
    MS-Off Ver
    365
    Posts
    4

    AVERAGEIF - single criterion in multiple columns?

    Hi everyone,

    I'm trying to calculate the average attendance for a team, using the AVERAGEIF function.

    In this example, I want to calculate the average attendance of Tottenham, which makes "Tottenham" the criteria. The problem is that Tottenham could either be the home team or the away team, and thus be in either column A or B. When using AVERAGEIF, Excel only seems to include rows if "Tottenham" in the first code column.

    This is the code I use:

    =AVERAGEIF(A2:B9,"Tottenham",C2:C9)

    I've included a screenshot, but I use a Norwegian version of Excel, so it's probably bit confusing.

    I'll be very grateful for your help!

    Averageif.JPG

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: AVERAGEIF - single criterion in multiple columns?

    Try

    =SUMPRODUCT(((A1:A50="Tottenham")+(B1:B50="Tottenham"))*(C1:C50))/SUMPRODUCT((A1:A50="Tottenham")+(B1:B50="Tottenham"))

  3. #3
    Registered User
    Join Date
    11-16-2016
    Location
    Norway
    MS-Off Ver
    365
    Posts
    4

    Re: AVERAGEIF - single criterion in multiple columns?

    Thanks John! I may be doing something wrong, but I keep getting the #VALUE! error when trying your suggestion.

  4. #4
    Forum Contributor
    Join Date
    08-23-2016
    Location
    India
    MS-Off Ver
    MS Office Professional Plus 2013
    Posts
    194

    Re: AVERAGEIF - single criterion in multiple columns?

    =(averageif(a2:a9,a13,c2:c9)+averageif(b2:b9,a13,c2:c9))/(countif(a2:a9,a13)+countif(b2:b9,a13))
    Ash

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: AVERAGEIF - single criterion in multiple columns?

    Check the values in the range (which you have used).

    OR

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

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

    Re: AVERAGEIF - single criterion in multiple columns?

    John's formula from post #2 returns #Value because there are Headers (Text Strings) in row 1
    =SUMPRODUCT(((A1:A50="Tottenham")+(B1:B50="Tottenham"))*(C1:C50))/SUMPRODUCT((A1:A50="Tottenham")+(B1:B50="Tottenham"))

    That should be

    =SUMPRODUCT(((A2:A9="Tottenham")+(B2:B9="Tottenham"))*(C2:C9))/SUMPRODUCT((A2:A9="Tottenham")+(B2:B9="Tottenham"))
    Last edited by Jonmo1; 11-16-2016 at 10:40 AM.

  7. #7
    Registered User
    Join Date
    11-16-2016
    Location
    Norway
    MS-Off Ver
    365
    Posts
    4

    Re: AVERAGEIF - single criterion in multiple columns?

    Quote Originally Posted by Ash_Maverick View Post
    =(averageif(a2:a9,a13,c2:c9)+averageif(b2:b9,a13,c2:c9))/(countif(a2:a9,a13)+countif(b2:b9,a13))
    Thanks Ash, I appreciate it!

    However, I'm afraid that gives an incorrect result, as that would sum the average from the A and B column, and then divide that sum again. It works for the example I gave, but if you change for example A9 from "Blabla" to "Tottenham", your formula reports the average to be 33 674, while 56 882 is correct...

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: AVERAGEIF - single criterion in multiple columns?

    Well spotted: I just posted my test without referring to the Op's post.

  9. #9
    Registered User
    Join Date
    11-16-2016
    Location
    Norway
    MS-Off Ver
    365
    Posts
    4

    Re: AVERAGEIF - single criterion in multiple columns?

    Quote Originally Posted by Jonmo1 View Post
    John's formula from post #2 returns #Value because there are Headers (Text Strings) in row 1
    =SUMPRODUCT(((A1:A50="Tottenham")+(B1:B50="Tottenham"))*(C1:C50))/SUMPRODUCT((A1:A50="Tottenham")+(B1:B50="Tottenham"))

    That should be

    =SUMPRODUCT(((A2:A9="Tottenham")+(B2:B9="Tottenham"))*(C2:C9))/SUMPRODUCT((A2:A9="Tottenham")+(B2:B9="Tottenham"))


    Of course, thanks a lot, both of you!

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

    Re: AVERAGEIF - single criterion in multiple columns?

    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. Use of Averageif on Multiple Columns
    By matubis.jp in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-13-2015, 05:19 PM
  2. [SOLVED] AVERAGEIF Multiple Columns
    By Markvx in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-29-2015, 08:48 AM
  3. Replies: 0
    Last Post: 04-16-2015, 02:45 AM
  4. AVERAGEIF function for multiple columns.
    By thatguytg53 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-11-2014, 06:17 PM
  5. [SOLVED] Looking up multiple values based on a single criterion
    By wmjenner in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-31-2013, 09:38 PM
  6. Averageif multiple columns
    By bronzboy in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-27-2013, 03:59 PM
  7. [SOLVED] Find Multiple instances of Single Criterion in Row & Return To a Single Col
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 05-09-2006, 10:10 PM

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