+ Reply to Thread
Results 1 to 43 of 43

If function checking 2 time ranges

  1. #1
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Post If function checking 2 time ranges

    I am trying to create a formula for below conditions for vehicles reaching factory in given time ranges;

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 11:59 then show "A" if after 11:59 then "B"

    trying to create a formula if a vehicles arrives anytime at factory it has benchmark for unloading and if vehicles takes more time then given benchmark then cell should show "A" or "B"
    Last edited by farhanthaheem; 03-31-2013 at 03:43 AM.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    assuming arrival time is in cell A2 and unloading time in cell B2

    case 1
    =IF(AND(HOUR(A2)>=12,HOUR(A2)<17, HOUR(B2)<=4),"A","B")

    case 2
    =IF(AND(HOUR(A2)>=17,HOUR(A2)<3, HOUR(B2)<=11),"A","B")

    case 3
    =IF(AND(HOUR(A2)>=3,HOUR(A2)<8, HOUR(B2)<=16),"A","B")

    case 4
    =IF(AND(HOUR(A2)>=8,HOUR(A2)<12, HOUR(B2)<=11),"A","B")

    with the unloaded time you say before 12:00 so 11:59 is OK and 12:00 is not
    in case 4 you say before 11:59 - so is 11:59 included or not

    hence I used the hour before in the unloaded - so <11 would include 11:59 , but not 12:00

    if 11:59 is not to be included then you can use the minute in the AND
    HOUR(B2)<=11, MINUTE(B2)<=58)
    Last edited by etaf; 03-27-2013 at 05:24 AM.

  3. #3
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    thanks for your reply.

    Your reply will definitely help me to create required logic which i have started,

    These 4 cases will be in added in single cell depending on what time vehicle arrives then check unloading time and show actual result, for example

    a vehicle arrives at 22:00 hours then cell should check report time belongs to case no 2 which has unloading benchmark 11:59 Hours, cell will check two times A1 (reporting time i-e 22:00), A2 (unloading time i-e 13:00) then cell should show B as time exceeds benchmark.

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    you may want to just check the starting time - and then use a nested if

    =IF(AND(HOUR(A2)>=12,HOUR(A2)<17) , IF( HOUR(B2)<=4),"PASS","Calculate the benchmark unloading time") , NOW repeat for the rest of the times arriving - etc IF(....

  5. #5
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    need your more support, could not get required results

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: If function checking 2 time ranges

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Sample Sheet vehicle in n out.xlsx

    I have attached sample sheet with different cases in which vehicles arrives and leaves factory.

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    we need to see the spreadsheet sample
    also I have added a formula
    =IF(AND(HOUR(A2)>=12,HOUR(A2)<17),IF(HOUR(B2)<=4,"PASS","Calculate the benchmark unloading time"),IF(OR(AND(HOUR(A2)>=17,HOUR(A2)<23),AND(HOUR(A2)>=0,HOUR(A2)<3)),IF(HOUR(B2)<=11,"PASS","Calculate the benchmark unloading time"),IF(AND(HOUR(A2)>=3,HOUR(A2)<8),IF(HOUR(B2)<=16,"PASS","Calculate the benchmark unloading time"),IF(AND(HOUR(A2)>=8,HOUR(A2)<12),IF(HOUR(B2)<=11,"PASS","Calculate the benchmark unloading time"),"time not in tests"))))

    which will deal with the cross midnight time scale

    also the loading time needs to be revised
    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 11:59 then show "A" if after 11:59 then "B"

    SO for
    case 1 unloaded after 12:00 and before 05:00 - crossing midnight - so calc needs to be modified to deal with midnight (as modified in case 2 arrival time)
    case 2 unloaded after 17:00 and before 12:00 - crossing midnight - so calc needs to be modified to deal with midnight (as modified in case 2 arrival time)
    case 3 unloaded after 03:00 and before 17:00
    case 4 unloaded after 08:00 and before 11:59 - although if a lorry can arrive upto 11:59 - then how can it be unloaded before 11:59

    can you confirm the modification to business rules for case 1,2 & 3 and also confirm the rules for case 4

  9. #9
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    cross posted

    just seen the spreadsheet
    Belongs to Case number 2, benchmark was 11:59 hours and vehile went out within benchmark, No extra payment

    so now you are talking vehicle went OUT

    what are the two time reports now ?
    before we had arrival time between a range and also an unloaded time

    now we have two times
    >time report - column D
    >out time - column G
    Last edited by etaf; 03-28-2013 at 09:59 AM.

  10. #10
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    There are 4 time ranges (business Rules)already mentioned below as cases 1 to 4 and each vehicle will check 2 data entries Vehicle Report Time (column D) and Vehicle out time (column G) in attached spreadsheet.

    Vehicle report time will decide which business rule (case) to be followed corresponding to which benchmark time are set, vehicle out time will decide extra payment to be given to transporter or not.

    I do not know if it is allowed to give skype ID, i can explain well on video conference.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Dear All, need your support to automate sheet.

    I have checked different possible solutions and thought this can be achieved by adding data in two columns, one column to select case then other column to check vehicle left factory on benchmark or not (Extra payment)

    I would appreciate if anyone could guide me if I am using correct formula for below case

    case 2
    vehicles reporting time is between 17:00 hours to next day 03.:00 hours

    =IF(AND(DAY(C2),HOUR(D2)>=17,(DAY(C2)+1),HOUR(D2)<3),"CASE4")

    i have attached sheet
    Attached Files Attached Files

  12. #12
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    see my post 8 and questions around the case

    for report time - whats the rules for each case ?
    for out time - whats the rules for that case

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 11:59 then show "A" if after 11:59 then "B"

    Case4 is not making sense based on in some cases it needs to unloaded when it arrives

  13. #13
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    thanks for your reply.

    oh! sorry it is typo mistake.... unloading benchmark for case 4 is 23:59 hours. sorry for inconvenience

  14. #14
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    I'm only checking the times - and not the days - is a lorry likely to go over a day
    Note I am checking the arrival time first and so that has to be true and then checking the out time

    case 1
    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 05:00 then show "NO" if after 05:00 then "YES"
    =IF(AND(HOUR(D4)>=12,HOUR(D4)<17),IF(OR(AND(HOUR(G4)>=0,HOUR(G4)<=4),AND(HOUR(G4)>=12,HOUR(G4)<=23)),"NO","YES"))

    the reason for question re if the lorry over 24hours can be seen here
    if a lorry arrives at 12:30 - then the time is true - so next we test the out time is between 12 and midnight and midnight to 3:59
    but if the lorry went out 24hours later 12:30 - then it would pass that part of the test

    so its probably best for a re-think and use the date - as you have that information from your sample - which i did not think you had based on your first post

    Case2
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 12:00 then show "No" if after 12:00 then "Yes"
    =IF(OR(AND(HOUR(D4)>=17,HOUR(D4)<23),AND(HOUR(D4)>=0,HOUR(D4)<3)),IF(OR(AND(HOUR(G4)>=17, HOUR(G4)<=23),AND(HOUR(G4)>=0,HOUR(G4)<=11)),"NO","YES"))

    case3
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 17:00 then show "No" if after 17:00 then "Yes"
    =IF(AND(HOUR(D3)>=3,HOUR(D3)<8),IF(HOUR(G3)<=16,"NO","YES"))

    case4
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours - REPORT TIME and unloaded after the REPORT TIME but before OUT TIME of 11:59 then show "No" if after 23:59 then "yes"
    =IF(AND(HOUR(D8)>=8,HOUR(D8)<12),IF((AND(HOUR(G2)>=8,HOUR(G2)<=23),"NO","YES"))

    so put all that together
    =IF(AND(HOUR(D2)>=12,HOUR(D2)<17),IF(OR(AND(HOUR(G2)>=0,HOUR(G2)<=4),AND(HOUR(G2)>=12,HOUR(G2)<=23)),"NO","YES"),IF(OR(AND(HOUR(D2)>=17,HOUR(D2)<23),AND(HOUR(D2)>=0,HOUR(D2)<3)),IF(OR(AND(HOUR(G2)>=17,HOUR(G2)<=23),AND(HOUR(G2)>=0,HOUR(G2)<=11)),"NO","YES"),IF(AND(HOUR(D2)>=3,HOUR(D2)<8),IF(HOUR(G2)<=16,"NO","YES"),IF(AND(HOUR(D2)>=8,HOUR(D2)<12),IF(AND(HOUR(G2)>=8,HOUR(G2)<=23),"NO","YES"),"NOT In RANGE"))))


    I have added to your spreadsheet in column H

    May not be a good idea to just test the time, but actually include the day

    perhaps you could try changing a few dates and see if it falls overs
    Attached Files Attached Files
    Last edited by etaf; 03-29-2013 at 10:31 AM.

  15. #15
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Thumbs up Re: If function checking 2 time ranges

    Excellent!!!!!!!!!

    It is working fine...... just had issues in very few lines for which i have attached sheet to check, yellow highlighted lines should have shown Yes but appearing NO and rest showing error not in range.



    THANK YOU BOSS!
    Attached Files Attached Files

  16. #16
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    is this the correct spreadsheet - looks like your original ?

  17. #17
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Yes this is the original sheet, i have still removed so many columns just left relevant data

  18. #18
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    not sure then what is not working

    I have expanded the tests so we have case1 - 4 and also the arrival time now tested as a fault finding exercise
    which rows are not working ?

    see the separate tests in row 10 headers - and testing is in row 11- 17 - testing the times in D2/G2 to D8/G8
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Please check Row number 1,4,5,6 & 7 cell showing not in range while for row number 2,3,8 Cell should show Yes but NO is appearing.

    not in range appearing for time exceeding 23:00 hours! result was showing correct in most of the cases.
    Attached Files Attached Files

  20. #20
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    not in range appearing for time exceeding 23:00 hours! result was showing correct in most of the cases.
    should have had D4<24 not 23 in the formula
    modified

    and the outime - is the next day - as far as the rule is concerned - i will need to think about that

  21. #21
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    this is now quite complex really, I'm sure there are easier ways

    IF(AND(HOUR(D4)>=12,HOUR(D4)<17),IF(OR(AND(DAY(G4)=DAY(C4), HOUR(H4)>=12,HOUR(H4)<=23),AND( DAY(G4)-DAY(C4)<=1, HOUR(H4)>=0,HOUR(H4)<=4)),"NO","YES"),IF(OR(AND(HOUR(D4)>=17,HOUR(D4)<24),AND(HOUR(D4)>=0,HOUR(D4)<3)),IF(OR(AND(DAY(G4)=DAY(C4),HOUR(D4)>=17, HOUR(H4)>=17,HOUR(H4)<=23),AND(DAY(G4)-DAY(C4)<=1,HOUR(H4)>=0,HOUR(H4)<=11)),"NO","YES"),IF(AND(HOUR(D4)>=3,HOUR(D4)<8),IF( AND(DAY(G4)=DAY(C4),HOUR(H4)<=16),"NO","YES"),IF(AND(HOUR(D4)>=8,HOUR(D4)<12),IF(AND(DAY(G4)=DAY(C4), HOUR(H4)>=8,HOUR(H4)<=23),"NO","YES"),"NOT In RANGE"))))


    I have added the case and arrival time to the attached spreadsheet

    i will break it all down a little later - but it maybe worth a good check and see if any more errors

    we also need to add another IF statement so that it ignores blank dates

    so

    =IF( B4="", "", IF(AND(HOUR(D4)>=12,HOUR(D4)<17),IF(OR(AND(DAY(G4)=DAY(C4), HOUR(H4)>=12,HOUR(H4)<=23),AND( DAY(G4)-DAY(C4)<=1, HOUR(H4)>=0,HOUR(H4)<=4)),"NO","YES"),IF(OR(AND(HOUR(D4)>=17,HOUR(D4)<24),AND(HOUR(D4)>=0,HOUR(D4)<3)),IF(OR(AND(DAY(G4)=DAY(C4),HOUR(D4)>=17, HOUR(H4)>=17,HOUR(H4)<=23),AND(DAY(G4)-DAY(C4)<=1,HOUR(H4)>=0,HOUR(H4)<=11)),"NO","YES"),IF(AND(HOUR(D4)>=3,HOUR(D4)<8),IF( AND(DAY(G4)=DAY(C4),HOUR(H4)<=16),"NO","YES"),IF(AND(HOUR(D4)>=8,HOUR(D4)<12),IF(AND(DAY(G4)=DAY(C4), HOUR(H4)>=8,HOUR(H4)<=23),"NO","YES"),"NOT In RANGE")))))

    also I notice you have excel 2003 - so the nested IFs maybe more than excel can handle - 7 I think - so we should be OK


    breaking it all down

    Case1
    IF(AND(HOUR(D4)>=12,HOUR(D4)<17),IF(OR(AND(DAY(G4)=DAY(C4), HOUR(H4)>=12,HOUR(H4)<=23),AND( DAY(G4)-DAY(C4)<=1, HOUR(H4)>=0,HOUR(H4)<=4)),"NO","YES")

    Arrival time between 12:00 and 16:59 - AND(HOUR(D4)>=12,HOUR(D4)<17) - if true we do the outtime test
    Outime (OR(AND(DAY(G4)=DAY(C4), HOUR(H4)>=12,HOUR(H4)<=23),AND( DAY(G4)-DAY(C4)<=1, HOUR(H4)>=0,HOUR(H4)<=4)

    DAY(G4)=DAY(C4), HOUR(H4)>=12,HOUR(H4)<=23) = goes out same day as arrives and goes out between 12:00 and 23:59
    AND( DAY(G4)-DAY(C4)<=1, HOUR(H4)>=0,HOUR(H4)<=4 = goes out next day (cant arrive next day, as would fail arrival time , so only test if day is less than or equal to 1 ) between 00:00 and 3:59

    Case2
    IF(OR(AND(HOUR(D4)>=17,HOUR(D4)<24),AND(HOUR(D4)>=0,HOUR(D4)<3)),IF(OR(AND(DAY(G4)=DAY(C4),HOUR(D4)>=17, HOUR(H4)>=17,HOUR(H4)<=23),AND(DAY(G4)-DAY(C4)<=1,HOUR(H4)>=0,HOUR(H4)<=11)),"NO","YES")

    Check arrival time is OR(AND(HOUR(D4)>=17,HOUR(D4)<24),AND(HOUR(D4)>=0,HOUR(D4)<3))
    between 17:00 - 23:59 and 0:00 to 2:59

    outtime (OR(AND(DAY(G4)=DAY(C4),HOUR(D4)>=17, HOUR(H4)>=17,HOUR(H4)<=23),AND(DAY(G4)-DAY(C4)<=1,HOUR(H4)>=0,HOUR(H4)<=11))

    check same day , and arrival later than 17:00 - and outtime between 17:00 and 23:59
    check the day is next day or less - and check the outtime is between 0:00 and 11:00

    Case3
    (AND(HOUR(D4)>=3,HOUR(D4)<8),IF( AND(DAY(G4)=DAY(C4),HOUR(H4)<=16),"NO","YES")
    if arrival time between 3:00 and 7:59 - (AND(HOUR(D4)>=3,HOUR(D4)<8)
    outtime must be same day and before 16:59 AND(DAY(G4)=DAY(C4),HOUR(H4)<=16

    Case4
    AND(HOUR(D4)>=8,HOUR(D4)<12),IF(AND(DAY(G4)=DAY(C4), HOUR(H4)>=8,HOUR(H4)<=23),"NO","YES")

    arrival time between 8:00 and 11:59 - AND(HOUR(D4)>=8,HOUR(D4)<12)
    outtime must be the same day and between 8:00 and 23:59 AND(DAY(G4)=DAY(C4), HOUR(H4)>=8,HOUR(H4)<=23)
    probably just need the HOUR(H4)<=23
    as HOUR(H4)>=8 is redundant as the arrival time test is already after 8:00


    see if all those breakdowns are as you required the rules to be

    we could also probably simplify - by using the one DATE cell for arrival and DATE cell for outgoing - rather than all the different cells where you have broken down ....
    Attached Files Attached Files
    Last edited by etaf; 03-30-2013 at 08:11 AM.

  22. #22
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Excellent!!!
    Checked all cases, all are showing correct results. I have got what I required.... Thanks a lot.

    Soon i will will be adding another condition in file

    Once again thanks for your help.

  23. #23
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Excellent!!!
    Checked all cases, all are showing correct results. I have got what I required.... Thanks a lot.

    Soon i will will be adding another condition in file

    Once again thanks for your help.

  24. #24
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    We can simply the IFs now to include the outtime as well as arrival time - i broke it out for diagnostic and testign purposes - that will reduce the IFs as there will not only be one per case and allow in excel 2003 the other conditions if required - but that will have to be later as out for next couple of days

  25. #25
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Hi there......

    adding one more condition in sheet

    Column G Showing factory locations U or D and Column F showing Vehicle Type 20 feet or 40 feet now there is another condition if a 40 feet vehicle arrives in Factory D at or after 00:00 hours then benchmark for unloading is 17:00 hours.

    This condition is only applicable in location D, i have also attached sheet for your reference.
    Attached Files Attached Files

  26. #26
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    we would need to simplify the IFs

    but need more information on how to handle the new criteria

    arrives in Factory D at or after 00:00 hours then benchmark for unloading is 17:00 hours
    - so is that anytime between 00:00 and 17:00 - and out by 17:00 the same day (although I know arriving at 17:00 and unloading an out by 17:00 would not be practical)

    what happens for other arrival times after 17:00 or practically would need to be earlier ? do we follow the other rules , as we may need to test for the size on all criteria - so ALL business rules would be useful for the NEW lorries

    what happens in factory U - just follow existing rules

    are you using excel 2003 - as that has a limit of 7 nested IFS and we may need to review the approach

  27. #27
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    This rule is only for Factory D with vehicle type 40.

    if a Truck reaches to factory D and vehicle type is 40 and arrives between 00:00 hours to 08:00 Hours then benchmark for unloading truck is 17:00 hours.

    There will be no change for factory U and rest all rules will remain same, I am using excel 2007.

  28. #28
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    we need to set up a set of conditions for Factory D and 40 - what happens when a truck arrives after 8:00 and before 00:00

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 11:59 then show "A" if after 23:59 then "B"

    as the other rules do not match
    case 4 , case1 are OK
    BUT then you need to modify the rules for case 2 between 17:00 -00:00

    OR is it simply the truck fails if arrives after 8:00 and before 00:00

    Its good to know you are on 2007 , as that can take a lot more nested IFs - so we can set up a test for factory D and truck 40 - and do all the tests to cover those conditions

  29. #29
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    there is correction in Case 4, i have updated benchmark for unloading.

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 00:00 then show "A" if after 00:00 then "B" (corrected benchmark)
    Case 5 if vehicle arrives at factory D and vehicle type is of 40 and arrival time is between 00:00 to 08:00 hours then unloading benchmark would be 17:00 hours.

  30. #30
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    i needed just the rules for
    factory D and vehicle type is of 40

    Case 5 if vehicle arrives at factory D and vehicle type is of 40 and arrival time is between 00:00 to 08:00 hours then unloading benchmark would be 17:00 hours.

    What happens at the other times and those time do not work with the current case 1-4

  31. #31
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Rules for factory D will remain same from Case 1 to case 4, only if vehicle type 40 arrives between 00:00 hour to 08:00 hours it benchmark for unloading will be 17:00 hours instead of 12:00 hours.

    Basically Rule number 03 is modified for vehicle type 40 in Factory D (Actual arrival time 03:00 to 07:59 hours is modified as arrival time 00:00 to 07:59 hours while benchmark remains same i-e before 17:00 hours)
    My skype ID is (farhanthaheem)

  32. #32
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    for some reason the forum wont allow me onto page 3 - but i read the reply on my email

    Rules for factory D will remain same from Case 1 to case 4, only if vehicle type 40 arrives between 00:00 hour to 08:00 hours it benchmark for unloading will be 17:00 hours instead of 12:00 hours.

    Basically Rule number 03 is modified for vehicle type 40 in Factory D (Actual arrival time 03:00 to 07:59 hours is modified as arrival time 00:00 to 07:59 hours while benchmark remains same i-e before 17:00 hours)
    My skype ID is (farhanthaheem)
    Just the D / 40 then - we need to modify RULE 2 to

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 23:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 00:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 00:00 then show "A" if after 00:00 then "B" (corrected benchmark)

    So those rules above now cover the 40 D conditions ?

  33. #33
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    No this will not work, existing formula will remain same there will be additional if condition to check this D / 40 conditions.

    Existing rules 1 to 4 will remain same for factory U and Factory D (vehicle Type 20)

  34. #34
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    leaving all the current conditions as written for all the other vehicles except the 40/D lorry

    SO JUST the 40/D lorry -
    No this will not work, existing formula will remain same there will be additional if condition to check this D / 40 conditions.
    but it cant follow the other rule case 2 - as that overlaps the arrival time - so case 2 and case 3 need to be modified for Lorry 40/D otherwise the arrival time overlaps

    is that not the case - ?

  35. #35
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    correct..... this will resolve this issue 40/D condition..

  36. #36
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    Does this Work ?

    Its quite complicated now - so needs a lot of testing , i could easily made some mistakes - I also started to simplify and mucked up - so I have just copied all the current rules into the new TRUE section and modified the case 2 and case 3 for the 40/D


    =IF(AND(F4=40,G4="D"),IF(AND(HOUR(J4)>=12,HOUR(J4)<17),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(N4)>=12,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=4)),"NO","YES"),IF(AND(HOUR(J4)>=17,HOUR(J4)<24),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(J4)>=17,HOUR(N4)>=17,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=11)),"NO","YES"),IF(AND(HOUR(J4)>=0,HOUR(J4)<8),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)<=16),"NO","YES"),IF(AND(HOUR(J4)>=8,HOUR(J4)<12),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)>=8,HOUR(N4)<=23),"NO","YES"),"NOT In RANGE")))),IF(AND(HOUR(J4)>=12,HOUR(J4)<17),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(N4)>=12,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=4)),"NO","YES"),IF(OR(AND(HOUR(J4)>=17,HOUR(J4)<24),AND(HOUR(J4)>=0,HOUR(J4)<3)),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(J4)>=17,HOUR(N4)>=17,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=11)),"NO","YES"),IF(AND(HOUR(J4)>=3,HOUR(J4)<8),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)<=16),"NO","YES"),IF(AND(HOUR(J4)>=8,HOUR(J4)<12),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)>=8,HOUR(N4)<=23),"NO","YES"),"NOT In RANGE")))))


    This is the first TEST
    =IF(AND(F4=40,G4="D"),

    So if it is 40 and D - then do all the following

    IF(AND(HOUR(J4)>=12,HOUR(J4)<17),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(N4)>=12,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=4)),"NO","YES"),IF(AND(HOUR(J4)>=17,HOUR(J4)<24),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(J4)>=17,HOUR(N4)>=17,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=11)),"NO","YES"),IF(AND(HOUR(J4)>=0,HOUR(J4)<8),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)<=16),"NO","YES"),IF(AND(HOUR(J4)>=8,HOUR(J4)<12),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)>=8,HOUR(N4)<=23),"NO","YES"),"NOT In RANGE")))),

    IF NOT 40/d - then do the old tests

    IF(AND(HOUR(J4)>=12,HOUR(J4)<17),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(N4)>=12,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=4)),"NO","YES"),IF(OR(AND(HOUR(J4)>=17,HOUR(J4)<24),AND(HOUR(J4)>=0,HOUR(J4)<3)),IF(OR(AND(DAY(M4)=DAY(I4),HOUR(J4)>=17,HOUR(N4)>=17,HOUR(N4)<=23),AND(DAY(M4)-DAY(I4)<=1,HOUR(N4)>=0,HOUR(N4)<=11)),"NO","YES"),IF(AND(HOUR(J4)>=3,HOUR(J4)<8),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)<=16),"NO","YES"),IF(AND(HOUR(J4)>=8,HOUR(J4)<12),IF(AND(DAY(M4)=DAY(I4),HOUR(N4)>=8,HOUR(N4)<=23),"NO","YES"),"NOT In RANGE")))))
    Attached Files Attached Files
    Last edited by etaf; 04-06-2013 at 08:01 AM.

  37. #37
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    not working

    would appreciate if you update formula on attached sheet.
    Attached Files Attached Files

  38. #38
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    would appreciate if you update formula on attached sheet.
    i did - see attached file on previous post

    so what condition can we use dates and just change the factory from D to U to see it change Yes/No

  39. #39
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    i have used an arrival time of 2:30 and unloaded by 16:30 - which for the OLD rules is a fail for case 2

    Case 1 if vehicle arrives at factory between 12:00 hours to 16:59 hours and unloaded before 05:00 then show "A" if after 05:00 then "B"
    Case 2 if vehicle arrives at factory between 17:00 hours to 02:59 hours and unloaded before 12:00 then show "A" if after 12:00 then "B"
    Case 3 if vehicle arrives at factory between 03:00 hours to 07:59 hours and unloaded before 17:00 then show "A" if after 17:00 then "B"
    Case 4 if vehicle arrives at factory between 08:00 hours to 11:59 hours and unloaded before 00:00 then show "A" if after 00:00 then "B" (corrected benchmark)
    Case 5 if vehicle arrives at factory D and vehicle type is of 40 and arrival time is between 00:00 to 08:00 hours then unloading benchmark would be 17:00 hours.

    BUT is TRUE for case 5 with a factory D

    so changing between a U and D should change the condition - which it does

    SO i need examples of where its wrong
    Attached Files Attached Files
    Last edited by etaf; 04-06-2013 at 08:50 AM.

  40. #40
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Seems i made a mistake in copying formula...... It is working fine.... checking entries and give you feedback in an hour.... Thanks for your support

  41. #41
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: If function checking 2 time ranges

    Ok - fingers crossed its all OK

  42. #42
    Registered User
    Join Date
    03-26-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: If function checking 2 time ranges

    Excellent!!!!!!

    all working fine........ now there are no more conditions. all clear. thanks again

  43. #43
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Thumbs up Re: If function checking 2 time ranges

    excellent :up:

+ 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