Solved

Excel Date and Time formula

Posted on 2012-03-23
20
846 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 47

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 81

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 17

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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 17

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 47

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 47

Expert Comment

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

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
 
LVL 17

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 47

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 17

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 17

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 17

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

756 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