+ Reply to Thread
Results 1 to 3 of 3

Calculate average difference between two columns of data [if criteria is met]

  1. #1
    Registered User
    Join Date
    05-29-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    58

    Calculate average difference between two columns of data [if criteria is met]

    Hi I hope you can help me with this one. I have two colmuns of dates and I want to calculate the average difference between those dates IF the first date falls in the last 12 rolling months. EG

    Col A Col B
    1/1/12 4/1/12
    25/5/12 26/5/12
    13/3/13 16/3/13
    19/4/13 26/4/13
    1/5/13 20/5/13

    In the example above the formula would calculate that 13/3/13, 19/4/13, 1/5/13 all fall in the last 12 months. It would then say that the differece between them is 3, 7, 19 and so the average is 9.66 days. Ideally this would be one formula in one cell, but it can be over several cells. Is this possible?

    Thanks in advance
    Last edited by samcdavies; 05-29-2013 at 04:55 AM. Reason: Meant 'last 12 months' not 'last year'

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Calculate average difference between two columns of data [if criteria is met]

    hi samcdavies, it is always recommended you upload a sample Excel file so that we don't have to re-create your data to test. i don't understand "IF the first date falls in the last year" & then you selecting "13/3/13, 19/4/13, 1/5/13". shouldn't last year be 2012? you can try these array formulas:
    =AVERAGE(IF(YEAR(A2:A6)=YEAR(TODAY())-1,B2:B6-A2:A6))

    if you meant this year, then:
    =AVERAGE(IF(YEAR(A2:A6)=YEAR(TODAY()),B2:B6-A2:A6))

    or if you meant last 12 months, then:
    =AVERAGE(IF(A2:A6>=EDATE(TODAY(),-12),B2:B6-A2:A6))

    all confirmed by pressing CTRL-SHIFT-ENTER to activate the array. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL-SHIFT-ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    05-29-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Calculate average difference between two columns of data [if criteria is met]

    Quote Originally Posted by benishiryo View Post
    hi samcdavies, it is always recommended you upload a sample Excel file so that we don't have to re-create your data to test.
    Sorry I didn't realise, I'll know for next time.

    Thanks for your suggestions. You were right I did want the last twelve rolling months. I'll try your ideas a little later. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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