+ Reply to Thread
Results 1 to 6 of 6

Combining Subtotal with criteria

  1. #1
    Registered User
    Join Date
    08-15-2018
    Location
    Portland, OR
    MS-Off Ver
    '13
    Posts
    16

    Angry Combining Subtotal with criteria

    I have hidden rows, and the column that has these 'unhidden' results need to be averaged, but only if it is from a corresponding criteria met. In my case, I want to average the "response time" of certain users, and response times are randomly sampled, and I hide the rows for data that did not get a sample response time. So I want to average each specific users response times.

    I have tried combining VLOOKUP by using:
    Please Login or Register  to view this content.
    Which won't even be accepted. I also trued Index and Match:

    Please Login or Register  to view this content.
    And that has #N/A return.

    Are there any other tricks to utilize the ability to average hidden cells that also must fit a criteria?

    I have attached a clean spreadsheet with no P.I.I. on it with the layout of the problem recreated. Excel '13 in use. Thanks a bunch!
    Attached Files Attached Files

  2. #2
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Combining Subtotal with criteria

    Try in "F537"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    copy paste right


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  3. #3
    Registered User
    Join Date
    08-15-2018
    Location
    Portland, OR
    MS-Off Ver
    '13
    Posts
    16

    Re: Combining Subtotal with criteria

    =IFERROR(AVERAGEIF($F$4:$F$530,F$536,$V$4:$V$530),"")
    The downside is that The average for cells V4:V530 takes the hidden cells as well. That's why I need subtotal's 101 function. Try it for yourself, do an =AVERAGE on cells V4:V41 (the end of the samples for User1), and you get 6:13, meanwhile, if you actually take the values of that set (V4:V41), and ignore the 0:00 response time, the average is 7:52. The cells in column V that display a 0:00 response time are ones that are not sampled, so I would like to not include those 0's in the data thats being averaged.

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Combining Subtotal with criteria

    avk has not allowed for the hidden rows.

    You don't need to use subtotal, as you're only hiding blanks in column U, you can use averagifs to ignore the blanks instead, this will do it.

    =AVERAGEIFS(V4:V530,F4:F530,F536,U4:U530,"<>")

    You will need to correct your headings though, in F536, you have 'User1, Sample' but in F4:F50 you have 'Sample, User1' The formula will not be able to match them together.

    You can do i with SUBTOTAL, but with your example, there is no need. This is messy and volatile.

    =AVERAGE(IFERROR(SUBTOTAL(1,OFFSET($V$1,IF($F$4:$F$530=F536,ROW($F$4:$F$530)-1),0)),""))

    Array confirmed with Shift Ctrl Enter.

  5. #5
    Registered User
    Join Date
    08-15-2018
    Location
    Portland, OR
    MS-Off Ver
    '13
    Posts
    16

    Re: Combining Subtotal with criteria



    Haha, I love that with excel, once the working answer is found, and you study it, its like "ohhhh, duh, that makes sense". Thanks Jason, those numbers check out with the correct averages. That is the first time that I've seen OFFSET used with IF. I'll have to keep that in mind. Cheers!

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Combining Subtotal with criteria

    Quote Originally Posted by PetGiraffe View Post
    That is the first time that I've seen OFFSET used with IF.
    You can use anything with anything as long as the correct data type is being returned.
    A lot of people are afraid to try a method that they haven't seen used before. What's the worst that could happen?
    Thinking out of the box always helps, often there are several ways to get the correct result and the method you first think of might not always be the best one. In the case of your requirement, I would choose AVERAGEIFS for efficiency over SUBTOTAL and OFFSET. It might not be practical if the criteria ar more complex, or change frequently, but here it is simple enough to use.

+ 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. Combining Subtotal, IF and ISNA
    By waiholi in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-17-2015, 03:27 AM
  2. Combining COUNTIF with SUBTOTAL?
    By garth66 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-06-2014, 09:38 PM
  3. Combining Subtotal and CountIf
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-16-2012, 04:42 AM
  4. Combining SUMIFS with SUBTOTAL
    By e_lad in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-16-2011, 11:23 AM
  5. Combining sumif, subtotal with filters?
    By November in forum Excel General
    Replies: 30
    Last Post: 11-04-2006, 03:27 PM
  6. SubTotal function. How do I keep reuse Subtotal criteria.
    By davidthegolfer in forum Excel General
    Replies: 0
    Last Post: 10-10-2006, 03:28 AM
  7. Combining SUMIF and SUBTOTAL functions
    By [email protected] in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-22-2005, 02:07 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