+ Reply to Thread
Results 1 to 7 of 7

Count Number of days from the most recent item

  1. #1
    Registered User
    Join Date
    05-01-2009
    Location
    North East (Durham)
    MS-Off Ver
    Excel 2003,7 and 10
    Posts
    63

    Count Number of days from the most recent item

    Hi - can you help.
    I have spreadsheet of data
    Date, Accident Type, Section

    In the accident type it will be either RIDDOR, Major or Minor, the section will be A,B,C or D
    The date will have a date in that box when it occured.

    What I want to do it count the number of days from the last RIDDOR date for each section - can you help

    I have attached example data set
    Attached Files Attached Files
    Last edited by batman1056; 12-15-2011 at 09:57 AM.
    Remember to edit *advance) your question and choose "Solved" if you have your answer

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Count Number of days from the most recent item

    What are the actual expected results for this sample set, and why?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Count Number of days from the most recent item

    Hi,

    Try this array (CTRL, SHIFT and ENTER)

    =DATEDIF(MAX(IF(($C$2:$C$25=G3)*($B$2:$B$25="RIDDOR"),$A$2:$A$25,"")),TODAY(),"d")

    in H3 and copied down.

    To return just the most recent date,

    =MAX(IF(($C$2:$C$25=G3)*($B$2:$B$25="RIDDOR"),$A$2:$A$25,""))

    also an array
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    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: Count Number of days from the most recent item

    Hi

    If i understoond well your target, then in H3, put the formula and drag down..

    =SUMPRODUCT(($C$2:$C$25=G3)*($B$2:$B$25="RIDDOR"))

    Hope to helps you.
    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.

  5. #5
    Registered User
    Join Date
    05-01-2009
    Location
    North East (Durham)
    MS-Off Ver
    Excel 2003,7 and 10
    Posts
    63

    Re: Count Number of days from the most recent item

    Expected results - so for each section we will know how many days we have operated in each section without a RIDDOR
    e.g. for A we might have 30 days; B might have 320 days

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Count Number of days from the most recent item

    Are any of the suggestions given above working for you?

    If no, can you elaborate on why A is 30 and B is 320?

  7. #7
    Registered User
    Join Date
    05-01-2009
    Location
    North East (Durham)
    MS-Off Ver
    Excel 2003,7 and 10
    Posts
    63

    Re: Count Number of days from the most recent item

    Quote Originally Posted by sweep View Post
    Hi,

    Try this array (CTRL, SHIFT and ENTER)

    =DATEDIF(MAX(IF(($C$2:$C$25=G3)*($B$2:$B$25="RIDDOR"),$A$2:$A$25,"")),TODAY(),"d")

    in H3 and copied down.

    To return just the most recent date,

    =MAX(IF(($C$2:$C$25=G3)*($B$2:$B$25="RIDDOR"),$A$2:$A$25,""))

    also an array
    Excellent - Solved

+ 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