+ Reply to Thread
Results 1 to 12 of 12

Average of values in a column based on another column

  1. #1
    Registered User
    Join Date
    10-29-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    11

    Average of values in a column based on another column

    I am looking to average 10 of the last 20 values based on a date. Column B contains dates, not specifically in order from oldest to current, and column C contains numeric values. I am wanting to average the 10 lowest values in column C based on the most current 20 dates in column B. Can anyone help with this?

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Average of values in a column based on another column

    It would be very helpful for us if you include a sample (in excel format)

  3. #3
    Registered User
    Join Date
    10-29-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    11

    Re: Average of values in a column based on another column

    Here is a sample of what I will have. there are 30 dates with corresponding values, and I want to average the 10 lowest values based on the 20 most recent dates.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-29-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    11

    Re: Average of values in a column based on another column

    Can anyone help on this?

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Average of values in a column based on another column

    Hoping this is somewhat what you want.. run the macro
    Attached Files Attached Files

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average of values in a column based on another column

    Can you sort the data by date in either ascending or descending order?

    Will there always be at least 20 dates and numbers to get the average from? If not, what should happen?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Registered User
    Join Date
    10-29-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    11

    Re: Average of values in a column based on another column

    the data is input from a used form, that is why it is not sorted. if I can get the formula to work for 20 dates, I can make the adjustments for less.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average of values in a column based on another column

    Not sure if this is what you want but you can try it and see.

    Array entered**:

    =AVERAGE(SMALL(IF(A2:A31>=LARGE(A2:A31,20),B2:B31),{1,2,3,4,5,6,7,8,9,10}))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Average of values in a column based on another column

    Good one, Tony...

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average of values in a column based on another column

    Thanks!

    Hoping that's what the OP was looking for.

  11. #11
    Registered User
    Join Date
    10-29-2014
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    11

    Re: Average of values in a column based on another column

    That works perfectly, thanks. I modified it to work for less then 20 dates and number of values to be averaged as I needed and it all works great. Thanks for your help Tony!

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average of values in a column based on another column

    You're welcome. Thanks for the feedback!

+ 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: 2
    Last Post: 06-06-2013, 08:29 AM
  2. Replies: 4
    Last Post: 12-12-2012, 11:26 AM
  3. Replies: 4
    Last Post: 12-12-2012, 10:37 AM
  4. SUM and Average of column values based on Month field
    By sourav_tech in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-06-2012, 12:15 AM
  5. Replies: 8
    Last Post: 02-16-2011, 05:03 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