# Thread: Change search range due to first result

1. ## Change search range due to first result

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. 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.  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. 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. That did it. Thank you. Is there a name for that type formula?

6. no, not really.

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.

=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. =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. 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
•