Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Excel Date and Time formula

Posted on 2012-03-23
Medium Priority
850 Views
I have a spreadsheet with 2 fields, with date and time. See below

Severity               Closed.TIME              Re-Assigned.TIME
Sev 3              2/2/2012 11:41      1/31/2012 16:09
Work Order      2/13/2012 10:07      12/22/2011 15:46
Work Order      3/5/2012 11:14      1/9/2012 18:12
Work Order      2/14/2012 11:28      1/18/2012 9:10
Sev 3              2/13/2012 12:13      2/6/2012 9:51
Sev 3              2/1/2012 7:46              1/30/2012 9:11
Sev 3              2/1/2012 14:46      1/31/2012 16:32
Sev 4              2/2/2012 17:11      1/30/2012 17:43

I want to calculate the total time it took to close the ticket. I assume I am going to create a formula using the 2 fields(re-assigned and closed)? I then want to look at the first column and see what severity it is, and compare the time to another table (See below) If I am within the time frame, I pass SLA, if not I fail.  For example if the total time is less the 24 hours and Column A has Sev3, then I want the formula to say "pass" if its over 24 hours, it should say "fail". Any assistance would be greatly appreciated!

Time Table:
Sev1        4 hours
Sev2        8 hours
sev3   24 hours
sev4   48 hours
0
Question by:Edward Pamias
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 8
• 6
• 4
• +1

LVL 49

Expert Comment

ID: 37759455
So the time span is the difference between columns 3 and 2?

What do you want to do with the "Work Order" rows?
0

LVL 81

Expert Comment

ID: 37759461
You might use a VLOOKUP formula like:
=IF(COUNTA(B2,C2)<>2,"",IF((B2-C2)<VLOOKUP(A2,LookupTable,2,FALSE),"Pass SLA","Fail"))

This formula assumes that A2, B2 and C2 are the severity, closed time and re-assigned time, while LookupTable is a named range with severity in the first column and allowable time in the second.

If the lookup table has time in hours (rather than days), you may need to multiply by 24:
=IF(COUNTA(B2,C2)<>2,"",IF(24*(B2-C2)<VLOOKUP(A2,LookupTable,2,FALSE),"Pass SLA","Fail"))

The bit with COUNTA is to make sure that you have entries in both closed time and re-assigned time before making the Pass/Fail test.
0

LVL 18

Author Comment

ID: 37759473
You can ignore the work orders for now. I will submit another question if need a formula for those. Or you can just add the result to say work order if that's in column A. What ever is easier.  Thanks!
0

LVL 18

Expert Comment

ID: 37759475
Have a look at the attached workbook.

HTH

Scot
27646642.xlsx
0

LVL 18

Expert Comment

ID: 37759482
Corrected workbook...
27646642.xlsx
0

LVL 18

Author Comment

ID: 37759493
P912, this looks good.... I was wondering can you add another field with what percentage I am within SLA, for example, if I closed the ticket in 2 hours and my sla is 4 hours.... can you have it give a result of 50%? This formula is pretty much right on the money of what I need.
0

LVL 49

Expert Comment

ID: 37759497
No need for time table

Private Sub CommandButton1_Click()
Dim i As Integer
Dim rStart As Range
Dim rEnd As Range
Dim diff As Integer

For i = 1 To Range("A1").End(xlDown).Offset(0, 0).Row
Set rStart = Range("B" & i)
Set rEnd = Range("C" & i)
diff = DateDiff("h", rEnd, rStart)
Select Case Range("A" & i)
Case "Sev1"
If diff < 4 Then
Range("D" & i).Value = "pass"
Else
Range("D" & i).Value = "fail"
End If
Case "Sev2"
If diff < 8 Then
Range("D" & i).Value = "pass"
Else
Range("D" & i).Value = "fail"
End If
Case "Sev3"
If diff < 24 Then
Range("D" & i).Value = "pass"
Else
Range("D" & i).Value = "fail"
End If
Case "Sev4"
If diff < 48 Then
Range("D" & i).Value = "pass"
Else
Range("D" & i).Value = "fail"
End If
Case Else
Range("D" & i).Value = Range("A" & i).Value
End Select
Next
End Sub
0

LVL 18

Expert Comment

ID: 37759502
Sure, give me a few minutes and I'll upload another workbook.
0

LVL 49

Expert Comment

ID: 37759504
In my code "Sev1", etc should be "Sev 1"
0

LVL 81

Expert Comment

ID: 37759505
Allowing for both Work Order and missing times,:
=IF(OR(COUNTIF(\$I\$2:\$I\$5,A2)=0,COUNTA(B2,C2)<>2),"",IF(24*(B2-C2)<VLOOKUP(A2,\$I\$2:\$J\$5,2,FALSE),"Pass","Fail"))

Returning the % of allowable:
=IF(F2="","",24*(B2-C2)/VLOOKUP(A2,\$I\$2:\$J\$5,2,FALSE))
Hours-Q27646642.xlsx
0

LVL 18

Author Comment

ID: 37759508
MartinLiss, I need to create a report with pivots and pie charts. With the info previously provided. Is this a macro you created? How would I use it?
0

LVL 49

Expert Comment

ID: 37759513
Put the code in a Command button or macro.
0

LVL 18

Expert Comment

ID: 37759518
Here's an updated workbook.

HTH

Scot
27646642.xlsx
0

LVL 18

Author Comment

ID: 37759556
p912s, for the failed SLA's I do not need to post a %.Looking at my data it looks like the format for the percetages should be Anything up to 50% should post <50 % anything up to 75\$ should post < 75% anything up to 100% should post < 100%

For example if my SLA percentage is 68% I would want the output to be < 75%. So far so good. I will test the oher examples out once I have tested this sample sheet. See sample below to see how it looks now... In the SLA meter is where I want the % to show as it is below. Instead of the % just have it display the above.

SLA Meter      Severity
< 50%                       Sev 3
< 50%                       Sev 3
0

LVL 18

Expert Comment

ID: 37759572
epamias ~ I'm happy to help, but your original question has been answered and you're adding on here. I'm a little nervous when you say "so far so good"; sounds like you're going to keep adding to this question.

Not displaying the % on the fails is a quick fix, all that's needed is to remove that part of the if formula.

As for bracketing the results, that would take another series of nested if's with our current structure.

Will that wrap up this question?

Thanks

Scot
0

LVL 18

Author Comment

ID: 37759591
yes it would..... Thank you.
0

LVL 18

Expert Comment

ID: 37759604
You're welcome, give me a few minutes...
0

LVL 18

Accepted Solution

p912s earned 2000 total points
ID: 37759619
Updated with %'s
27646642.xlsx
0

LVL 18

Author Closing Comment

ID: 37759631
This is great! Thank you! Again, thanks to all for your input.
0

LVL 18

Expert Comment

ID: 37759649
You're welcome!

Scot
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question