+ Reply to Thread
Results 1 to 18 of 18

calculate average of positive values only

  1. #1
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    calculate average of positive values only

    Is there a way to calculate the average of only values that are > 0, and separately only values that are <0, in a list of 500 values that contains both positive and negative values?

    p.s. I'd prefer not to break the data out into additional columns because the spreadsheet is already quite large

    many thanks,

  2. #2
    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: calculate average of positive values only

    Is there a way to calculate the average of only values that are > 0,
    =AVERAGEIF(A:A,">0",A:A)

    ..and separately only values that are <0, in a list of 500 values that contains both positive and negative values?

    p.s. I'd prefer not to break the data out into additional columns because the spreadsheet is already quite large
    What do you mean when you say separate the negative values but you don't want an extra column?

    Don't you need a list with all negative values?
    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.

  3. #3
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: calculate average of positive values only

    I don't know where your data is, but you can run this macro to find both averages.

    Please Login or Register  to view this content.
    ~~LaffyAffy13~~

    If I have helped you solve your problem, please be sure to click at the bottom left of my post.

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: calculate average of positive values only

    Fotis, I don't believe they want to separate the values, I believe they want to find the average of the negative values, separately. Also, use Fotis's method, its way easier hahaha

  5. #5
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    I used 'average' to keep my question simple, but I'm actually looking to calculate the covariance and variance for values >0; and values<0. Is there an equivalent 'averageif' function for covariance or variance? My cell formula looks like this:

    Please Login or Register  to view this content.
    I don't want an extra column to for efficient data management.... there are already more than 100 columns in the spreadsheet, and I'd prefer not to double or triple the number of columns by separating positive and negative values for each column. Thanks

  6. #6
    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: calculate average of positive values only

    As i don't have any more free time, i'll not be able to continue on this today. BUT even if i had(time) i am not able to understand your goal, without a small sample workbook.

  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,938

    Re: calculate average of positive values only

    Sometimes, adding an extra helper column or 2 can in fact be more efficient/faster than creating a hulking big, involved formula. Im not saying that is is (or is not) 1 of those situations, just that you should keep your options open
    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

  8. #8
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    beta.xlsm

    This macro will work for 1 column of data, but the actual problem has about a 100 columns. I've attached the file... essentially I'm trying to calculate all values in rows 35 to 52, but with only positive values (and will do it again separately for only negative values). Any ideas appreciated!

    Thanks, Don

  9. #9
    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,938

    Re: calculate average of positive values only

    When I load your file, ALL i get is errors from D:CJ

  10. #10
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Unhappy Re: calculate average of positive values only

    beta2.xlsx

    I resaved as an excel workbook (instead of macro-enabled)... maybe this will help. it works on my machine and I'm using MS Office professional 2010.

  11. #11
    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,938

    Re: calculate average of positive values only

    its not the macro-enabled part, you are using a function that 2007 does not recognise

  12. #12
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    Perhaps 2007 doesn't recognize the 'index function' ? The formula in the cells from D:CJ is essentially this:


    Please Login or Register  to view this content.

  13. #13
    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,938

    Re: calculate average of positive values only

    no, its the _xlfn.COVARIANCE.P() part

    the formula itself is irrelevant to your question here, so maybe you could just value those answers and upload again? (save as a COPY so you dont mess up your file!!!!)

  14. #14
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    beta3.xlsx

    I've greatly simplified the file/formula and re-uploaded. If this doesn't open correctly let me know. Hopefully this helps conceptualize the issue.

    Thanks!!

  15. #15
    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,938

    Re: calculate average of positive values only

    perhaps this...

    =AVERAGEIF($D$18:$D$34,">0") returns 0.0133493731922283
    and
    =AVERAGEIF($D$18:$D$34,"<0") returns -0.0229242524337096

  16. #16
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    that works for calculating the average... is there an equivalent or other creative approach to do the same for calculating the variance or covariance?

    Don

  17. #17
    Registered User
    Join Date
    03-29-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: calculate average of positive values only

    that works for average... any suggestions for doing the same when calculating variance or covariance?

    Don

  18. #18
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: calculate average of positive values only

    you need an array formula like
    =VAR(IF($D$18:$D$34>0,$D$18:$D$34))
    entered with ctrl+shift+enter
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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. Replies: 8
    Last Post: 12-13-2012, 01:15 PM
  2. How to calculate the average of minimum values
    By gideone in forum Excel General
    Replies: 9
    Last Post: 08-31-2011, 03:56 AM
  3. Calculate weighted average with missing values
    By Deiseman in forum Excel General
    Replies: 9
    Last Post: 06-08-2010, 10:03 AM
  4. I need a formula to calculate average values by day date
    By tdraa in forum Excel - New Users/Basics
    Replies: 16
    Last Post: 12-04-2006, 04:56 PM
  5. Looking-up Columns w/calc'd Values ONLY to Calculate Average
    By sony654 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-21-2006, 01:25 AM

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