+ Reply to Thread
Results 1 to 8 of 8

AverageIF using multiple criteria in different columns in multiple worksheets

  1. #1
    Registered User
    Join Date
    05-02-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    7

    AverageIF using multiple criteria in different columns in multiple worksheets

    I'm working in a workbook with two worksheets: one summary tab and one data tab (SQL Results). The data tab is attached and contains the values that the summary tab is aggregating using several SUMPRODUCT formulas.

    In the summary tab, the SUMPRODUCT formulas are returning counts of records that meet multiple criteria, as shown in this formula:

    cell B5 contains =SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1))
    Result is 8 records.


    On the Summary tab, I am trying to use AVERAGEIF or IF(...(AVERAGE(...)) to calculate the average of the amounts in Column Y (FUND1_PAID) IF the criteria in the SUMPRODUCT formula are met. My formula seems to be averaging the entire Column Y despite my limiting attempts:

    =IF((SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!J:J="1")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1))),(AVERAGE('SQL Results'!Y:Y)))

    This array version isn't quite doing the trick, either. I confirmed with CTRL+SHIFT_ENTER:

    =AVERAGE(IF(('SQL Results'!L:L="I")*('SQL Results'!J:J="1")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1),'SQL Results'!Y:Y))

    Any thoughts?

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    You're pretty close. SUMPRODUCT can be both the count of criteria, and the sum of criteria.

    SUM of results where criteria is met: SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1)*('SQL Results'!Y:Y))

    COUNT where met: SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1))


    Average = SUM / COUNT

    =SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1)*('SQL Results'!Y:Y)) ÷
    SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1))
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    1st, I would caution against using entire ranges in SUMPRODUCT, it can become a resource-hog

    2nd, have you had a look at using the averageifS() function for this?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    05-02-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    Yeah, I'm bumping up against that resource issue now, apparently. I've gotten some "Excel is out of resources" messages. Maybe I need to rethink the summary tab.

    I tried daffodil11's suggestion, but got a #VALUE error. Here's what I entered:

    =SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1)*('SQL Results'!Y:Y))/SUMPRODUCT(('SQL Results'!L:L="I")*('SQL Results'!F:F="201340")*('SQL Results'!I:I="Y")*('SQL Results'!P:P>0.949)*('SQL Results'!T:T<1))

    Excel help mentions disparate data types, so maybe my Y and I indicators are fighting with my numeric values?


    My original thought with the summary tab was to tag each record in the data tab with a Block #, depending on the values in the F, L, I, P and T columns. Each record would belong in only one Block and then I could do simple summaries and counts based on the Block indicators in the data tab. I couldn't figure out how to make that work without manually filtering for each of the 32+ Blocks that the data set requires. I wonder if a very long nested IF statement would allow me to build Block #s for each row.

    Thank you both for answering, by the way! I'm enjoying my first day on the forum

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    not sure what answer you were expecting, but using....
    =AVERAGEIFS($Y:$Y,$L:$L,"I",$J:$J,1,$F:$F,201340,$I:$I,"y",$P:$P,">0.949",$T:$T,"<1")

    I get 5336.571429

  6. #6
    Registered User
    Join Date
    05-02-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    That's exactly the answer I was expecting. And now I know about the AVERAGEIFS forumula. Thanks very much for your help - that got me over the hump, and I can get back to working on the rest of this model. Have a great weekend!

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    haha happy to help

    If this answered your question, please take a moment to mark the thread as "solved" - it helps keep things neat and tidy lol, and consider adding the reputation to those that helped (see points 2 & 3 below my 1st post to you)

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: AverageIF using multiple criteria in different columns in multiple worksheets

    Thanks for the rep and kind words

+ 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] AVERAGEIF Multiple Columns
    By Markvx in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-29-2015, 08:48 AM
  2. AVERAGEIF function for multiple columns.
    By thatguytg53 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-11-2014, 06:17 PM
  3. Averageif multiple columns
    By bronzboy in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-27-2013, 03:59 PM
  4. averageif formula with multiple criteria
    By CPitta in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-08-2013, 12:56 PM
  5. AVERAGEIF (Multiple Worksheets)
    By graybush in forum Excel General
    Replies: 1
    Last Post: 11-02-2011, 09:59 PM

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