Results 1 to 10 of 10

Thread: Change search range due to first result

  1. #1

    Change search range due to first result



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello,
    I have a set or criteria that requires 2 or more separate one hour periods to have >=2 cars. Keep in mind, it doesn't have to be whole hours. Each 15 min starts a new 60 min period. As shown below, at 12:00 1 car returns No. 12:15 returns Yes. 12:30 and 12:45 have 2 or more but don't count anymore because they occupy the same 60min as the first instance.
    I am trying to come up with a formula that finds the first instance of >=2 in the cars column. It then must skip the next three 15 min intervals and continue the search.

    A B C D E
    1 Time Cars
    2 12:00 1 No
    3 12:15 2 Yes
    4 12:30 2 N/A
    5 12:45 3 N/A
    6 13:00 1 N/a
    7 13:15 1 No
    8 13:30 2 Yes
    9 13:45 1 N/A
    10 14:00 2 N/A

  2. #2
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,437
    Articles
    0
    Excel Version
    Excel 2016
    Does this formula work for you?

    =IFERROR(IF(COUNTIF(B$2:B2,">=2")=1,"Yes",IF(AND(B2>=2,A2>=LOOKUP(2,1/($C$1:C1="Yes"),$A$1:A1)+TIME(0,45,0)),"Yes","No")),"No")

    copied down


  3. #3
    A B C D
    1 Time Cars
    2 12:00 1 No
    3 12:15 2 Yes
    4 12:30 2 N/A
    5 12:45 3 N/A
    6 13:00 1 N/a
    7 13:15 1 No
    8 13:30 2 Yes
    9 13:45 1 N/A
    10 14:00
    It did not. I made an error in the original chart. The A column is time. Numbers 1-10 were row numbers.

  4. #4
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,437
    Articles
    0
    Excel Version
    Excel 2016
    My formula was based on that (i.e. the header, Time, is in A1. My formula would then be placed in C2 and copied down.

    here are my results:

    Time Cars
    12:00 1 No
    12:15 2 Yes
    12:30 2 No
    12:45 3 No
    13:00 1 No
    13:15 1 No
    13:30 2 Yes
    13:45 1 No
    14:00 2 No


  5. #5
    That did it. Thank you. Is there a name for that type formula?

  6. #6
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,437
    Articles
    0
    Excel Version
    Excel 2016
    no, not really.


  7. #7
    Hello, I just found a problem with the formula. Using our original inputs, it works fine. When I use different numbers, I get "Yes" down the column. For example, if I have 1 car at 12:00, 2 cars at 12:15 and one car the rest of the way, I get yes from 12:15 down.

  8. #8
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,437
    Articles
    0
    Excel Version
    Excel 2016
    Try this adjustment:

    =IFERROR(IF(AND(B2=2,COUNTIF(B$2:B2,">=2")=1),"Yes",IF(AND(B2>=2,A2>=LOOKUP(2,1/($C$1:C1="Yes"),$A$1:A1)+TIME(0,45,0)),"Yes","No")),"No")


  9. #9
    =IFERROR(IF(AND(B2>=2,COUNTIF(B$2:B2,">=2")=1),"Yes",IF(AND(B2>=2,A2>=LOOKUP(2,1/($C$1:C1="Yes"),$A$1:A1)+TIME(0,60,0)),"Yes","No")),"No").

    I worked with some mods as shown in red above. Thanks again.

  10. #10
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,437
    Articles
    0
    Excel Version
    Excel 2016
    Ok. Good.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •