+ Reply to Thread
Results 1 to 17 of 17

Getting average of subtotals only if value of individual cells are greater than zero

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Getting average of subtotals only if value of individual cells are greater than zero

    http://www.excelforum.com/excel-formulas-and-functions/961918-how-to-use-countif-with-subtotal-so-it-works-with-filters.html[/URL]I'm trying to get the average for a range of data only in the value in the individual cells is greater than zero. The data I'm trying to average is in cells L2:L619 before filtering.

    I tried to follow a formula on a different thread - changing it to =SUMPRODUCT(SUBTOTAL(1,OFFSET(L2,ROW(L2:L619)-ROW(L2),0)),(L2:L619=">0")+0) but it's not working - any idea what I'm doing wrong?

    Link to other thread:
    "http://www.excelforum.com/excel-formulas-and-functions/961918-how-to-use-countif-with-subtotal-so-it-works-with-filters.html"

  2. #2
    Registered User
    Join Date
    05-11-2007
    Location
    Bangalore, India
    MS-Off Ver
    MS Office 2013
    Posts
    58

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Dear Anthonykinsella,

    If you are using Excel 2007, then try out with Formula "AVERAGEIFS"...

    Regardsm
    Harish S

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Try this ARRAY formula.

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    -- Array(CSE) { }, formulae are confirmed with Control+Shift+Enter.
    Not just Enter.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

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

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Thanks Fotis1991 - that works for the full list - but not if I filtered for say only July invoices.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Looks strange..In this case:

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. 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 demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  6. #6
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Ok sample workbook attached.

    On the first tab I have put a selection of my data - at the bottom is the normal subtotal formula & also your formula. In columns O:P I have replicated columns K:M but have deleted any negative values - the highlighted cells show the correct (desired) answers.

    On the second tab I have filtered the data to show only payments made in July'13 - as you can see the formula you advised doesn't change - again the correct (desired) answers are highlighted
    Attached Files Attached Files

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Hi,

    Several things:

    Firstly, the SUBTOTAL formula, since it is using column A as a reference, and since this column is textual, using 2 for the function_num parameter will not work: either use 3 or select a different column (e.g. containing numerical data only) to use as its array reference.

    Secondly, I am not sure what the ">0" is supposed to achieve in this construction.

    Thirdly, the starting reference for the OFFSET formula (A1 in this case) needs to be fixed relative to the column so that when dragged across to the right, it remains so (otherwise you may encounter similar issues with the SUBTOTAL function as explained in my first point).

    Fourthly, it does not appear that this formula was committed as an array formula when I opened your attachment.

    All in all, your formula in column O should be:

    =AVERAGE(IF(SUBTOTAL(3,OFFSET($A1,ROW($A$2:$A$217)-ROW($A$1),0,1)),IF(O2:O217>0,O2:O217)))

    Regards
    Click * below if this answer helped

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

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Note also that your desired total in column P of 21 is incorrect, since this average is derived from an array including the zero in row 69, which contradicts the condition in the formula of excluding values not greater than 0.

    Regards

  9. #9
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Ok confused! Firstly by using 3 in the subtotal is that not count rather than average?

    When I put that formula into my test spreadsheet I get a #value! error

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    No!

    The AVERAGE function is doing the averaging! The SUBTOTAL function is used as it is compatible with evaluating arrays containing hidden/filtered rows - the technique in this construction may require some explanation, which I will try later if you really want.

    Are you sure you know how to enter array formulas? Are you sure that you're entering it in a workbook which is identical to that which you posted?

    Regards

  11. #11
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Yes I'm entering it into the same type of workbook - never used array formulas

    No need for the attitude either

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    I don't see any bad attitude! I see a man who tries-hard- to helps you! Pls..!

    -- Array(CSE) { }, formulae are confirmed with Control+Shift+Enter.
    Not just Enter.

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Asking someone whether they are 'sure' that they have understood and followed instructions is not, in my opinion, "attitude", and, given the amount of time I put into an analysis of your problem, I am slightly disappointed that you would feel that way.

    Regards

  14. #14
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    That means nothing to me - I'll go to excel help & look up array formula - thanks

  15. #15
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    You are welcome!

    May you pls mark your thread as SOLVED as per forum rules?

  16. #16
    Registered User
    Join Date
    10-17-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Trying to - just trying to find out how

  17. #17
    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,945

    Re: Getting average of subtotals only if value of individual cells are greater than zero

    Perhaps you mis-interpreted XOR's reason for asking the question he did. I have seen many instances where a member (new or otherwise) has just entered an array formula by just using ENTER, instead of CSE - it looked to me like he was confirming that you knew how to enter an array - many members dont know how.

    1 if the biggest draw-backs of a written communication medium like these forums, is that you cannt see/hear how the question/statement was phrased, so it leaves a lot to interpretation
    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

+ 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] Conditional formatting if equal or greater than average in the range of cells
    By Abu Abdurakhim in forum Excel General
    Replies: 7
    Last Post: 05-28-2013, 10:01 AM
  2. I need to find the Average of separate cells Greater than 0
    By SpeedyOne18 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-14-2013, 10:31 PM
  3. Replies: 2
    Last Post: 10-20-2008, 12:53 AM
  4. paste only subtotals, not individual date that makes up subtotal
    By judybart in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-14-2006, 05:35 PM
  5. Average If Adejecent Cells Greater Than Zero
    By REW2705 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-20-2005, 08:05 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