Solved

Excel Date and Time formula

Posted on 2012-03-23
20
830 Views
Last Modified: 2012-03-23
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
Comment
Question by:Edward Pamias
  • 8
  • 6
  • 4
  • +1
20 Comments
 
LVL 45

Expert Comment

by:Martin Liss
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 80

Expert Comment

by:byundt
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 14

Author Comment

by:Edward Pamias
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

by:p912s
ID: 37759475
Have a look at the attached workbook.

HTH

Scot
27646642.xlsx
0
 
LVL 18

Expert Comment

by:p912s
ID: 37759482
Corrected workbook...
27646642.xlsx
0
 
LVL 14

Author Comment

by:Edward Pamias
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 45

Expert Comment

by:Martin Liss
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

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

Expert Comment

by:Martin Liss
ID: 37759504
In my code "Sev1", etc should be "Sev 1"
0
 
LVL 80

Expert Comment

by:byundt
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 14

Author Comment

by:Edward Pamias
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 45

Expert Comment

by:Martin Liss
ID: 37759513
Put the code in a Command button or macro.
0
 
LVL 18

Expert Comment

by:p912s
ID: 37759518
Here's an updated workbook.

HTH

Scot
27646642.xlsx
0
 
LVL 14

Author Comment

by:Edward Pamias
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

by:p912s
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 14

Author Comment

by:Edward Pamias
ID: 37759591
yes it would..... Thank you.
0
 
LVL 18

Expert Comment

by:p912s
ID: 37759604
You're welcome, give me a few minutes...
0
 
LVL 18

Accepted Solution

by:
p912s earned 500 total points
ID: 37759619
Updated with %'s
27646642.xlsx
0
 
LVL 14

Author Closing Comment

by:Edward Pamias
ID: 37759631
This is great! Thank you! Again, thanks to all for your input.
0
 
LVL 18

Expert Comment

by:p912s
ID: 37759649
You're welcome!

Scot
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now