+ Reply to Thread
Results 1 to 5 of 5

Subtotal Average Function - Conditional based on value in a specific column

  1. #1
    Registered User
    Join Date
    07-06-2015
    Location
    Los Angeles
    MS-Off Ver
    Office 2013
    Posts
    4

    Subtotal Average Function - Conditional based on value in a specific column

    Hi All,

    I'm trying to conduct an average of prices based on filtered data, only if a specific column is not equal to a specific letter.

    Example : Column A contains Prices. Column B contains a purchase code.

    I want to be able to conduct an average of prices based on what the user has filtered on, so I'm using the subtotal average function. I only want the data to calculate if Column B is not equal to the letter "E".

    Can anybody help? Been having major difficulty with this. Thanks!

  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
    44,053

    Re: Subtotal Average Function - Conditional based on value in a specific column

    Try =averageif(B:B,"<>E",A:A)
    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 Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Subtotal Average Function - Conditional based on value in a specific column

    @Glenn

    OP specified for filtered data (i.e. solution will require SUBTOTAL).

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Subtotal Average Function - Conditional based on value in a specific column

    The simple way to do this is with a helper column, e.g. In a blank column like column Z use this formula in Z2 copied down:

    =SUBTOTAL(2,A2)

    Then the formula for averaging with your condition but only visible rows would be

    =AVERAGEIFS(A:A,B:B,"<>E",Z:Z,1)

    If you don't want a helper column try an array formula like this

    =AVERAGE(IF(B$2:B$100<>"E",IF(SUBTOTAL(2,OFFSET(A$2,ROW(A$2:A$100)-ROW(A$2),0)),A$2:A$100)))

    Confirmed with CTRL+SHIFT+ENTER

    adjust ranges as required
    Audere est facere

  5. #5
    Registered User
    Join Date
    07-06-2015
    Location
    Los Angeles
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: Subtotal Average Function - Conditional based on value in a specific column

    Quote Originally Posted by daddylonglegs View Post
    The simple way to do this is with a helper column, e.g. In a blank column like column Z use this formula in Z2 copied down:

    =SUBTOTAL(2,A2)

    Then the formula for averaging with your condition but only visible rows would be

    =AVERAGEIFS(A:A,B:B,"<>E",Z:Z,1)

    If you don't want a helper column try an array formula like this

    =AVERAGE(IF(B$2:B$100<>"E",IF(SUBTOTAL(2,OFFSET(A$2,ROW(A$2:A$100)-ROW(A$2),0)),A$2:A$100)))

    Confirmed with CTRL+SHIFT+ENTER

    adjust ranges as required
    Thank you so much! This solved it. I'm trying to understand what the code is actually saying, but thank you so much for providing it!

+ 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. Conditional Formatting - Format row based on cell value in specific column
    By Kite3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-08-2013, 12:23 AM
  2. conditional subtotal function
    By dreamz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-18-2012, 05:54 AM
  3. Replies: 1
    Last Post: 08-17-2012, 08:16 PM
  4. Replies: 2
    Last Post: 08-10-2012, 11:52 PM
  5. How do I nesting subtotal function within average function in Exc
    By Amy Yeh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-19-2005, 04:06 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