Print Page | Close Window

Trouble with IF

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9655
Printed Date: 19 May 2024 at 4:11pm


Topic: Trouble with IF
Posted By: Mendoza
Subject: Trouble with IF
Date Posted: 11 Apr 2010 at 11:48pm
I would really appreciate your help on this one!
 
I am trying to write a formula which highlights any entry with subcategory of "server", where the difference between the date and time the call was opened and closed is greater than one hour.  This hour SLA should only be applicable during our service hours which is 8am - 6pm.
 
So far I have this:
 
TimeVar SetStart := TimeValue(08,00,00);     
TimeVar SetEnd   := TimeValue(18,00,00);
 
If{subcategory.description}="Server"
 AND (DateDiff("h",{request.opened_date_time},{request.closed_date_time})>1 
  AND time({request.opened_date_time}) IN SetStart TO SetEnd   
   AND time({request.closed_date_time}) IN SetStart TO SetEnd)  
    THEN ({request.closed_date_time};crRed)       
      ELSE ({request.closed_date_time};crNoColor) 
 
This works fine for the most part however it is not accurately capturing all the breached calls.  For example, there's a call which was opened before 8am, closed before 6pm but took longer than one hour to fix and this is not being highlighted.  I understand that there is a problem with the middle of my formula, where I'm specifying the service hours.  I need to capture all breaches beside those where the call was both opened and closed outside of our service hours.
 
It's a long one, but I hope it makes sense and I hope one of you lovely people can prevent me from pulling any more of my hair out.
 
Thanks!!



Replies:
Posted By: lockwelle
Date Posted: 13 Apr 2010 at 3:37am

While it may be a more complex calculation, why don't you determine the length of time to fix the incident and then display the ones that have a length > 1 hour...this sounds like what you want.

You started out saying you only wanted calls that occur during the service hours, but then say you want calls that are outside of service hours.  It would seem that you need to clearly define what your goal is, and then finding a solution will much easier.
 
HTH


Posted By: Mendoza
Date Posted: 13 Apr 2010 at 3:50am
Hi Lockwelle,
 
I think the fact that I am unfamiliar with creating formula is a severe handicap.  In essence we have numerous call categories and subcategories with their own associated SLAs like 1 hour, 1 day, 3 days etc.  I need to highlight all calls which have exceeded their SLA target, excluding calls which were both opened and closed outside of our service hours of 8am to 6pm.  Therefore a call opened at 7.30am but closed at 10.00 with an SLA target of 1 hour, should be highlighted as a breach whilst a call opened at 7pm and closed at 6am should not.
 
I hope this is a little clearer.
 
Thanks!
 
 


Posted By: DBlank
Date Posted: 13 Apr 2010 at 3:55am
Switch it to using an OR statement when evaluating the time falling between your regular hours
 
TimeVar SetStart := TimeValue(08,00,00);     
TimeVar SetEnd   := TimeValue(18,00,00);
 
If{subcategory.description}="Server"
 AND (DateDiff("h",{request.opened_date_time},{request.closed_date_time})>1 
  AND
(time({request.opened_date_time}) IN SetStart TO SetEnd   
or time({request.closed_date_time}) IN SetStart TO SetEnd)) 
 
    THEN ({request.closed_date_time};crRed)       
      ELSE ({request.closed_date_time};crNoColor) 


Posted By: Mendoza
Date Posted: 13 Apr 2010 at 4:17am
Hi DBlank,
 
Thanks for your suggestion, which I tried.  Unfortunately it is highlighting calls which are not considered breaches eg call opened at 02.00am and closed at 08.30am.  As our service hours are 08.00am to 6.00pm, this call was effectively resolved within the SLA.


Posted By: DBlank
Date Posted: 13 Apr 2010 at 4:25am

So your condition is not more than 1 hour but rather more then one hour of 'work time', correct?

What do you do for the end of the day? Meaning if a call came in at 5:01 it will never be a breach because your day ended at 6:00...


Posted By: Mendoza
Date Posted: 13 Apr 2010 at 4:32am
Exactly DBlank, nicely put!
 
With regards to your next question, as long as the call is closed before 8:02 the next morning, it's within SLA.


Posted By: DBlank
Date Posted: 13 Apr 2010 at 4:50am
TimeVar SetStart := TimeValue(08,00,00);     
TimeVar SetEnd   := TimeValue(18,00,00);
 
If{subcategory.description}="Server"
 AND (DateDiff("h",
if time({request.opened_date_time}) < SetStart then date({request.opened_date_time}) + SetStart  else
if time({request.opened_date_time}) > SetEnd then dateadd('d',1,date({request.opened_date_time})) + SetStart  else {request.opened_date_time},{request.closed_date_time})>1 
 
    THEN ({request.closed_date_time};crRed)       
      ELSE ({request.closed_date_time};crNoColor) 
 
NOt sure of your logic on what to do if the ticket was between 6 and midnight. I added 1 day to it but that assumes you are 'open' 7 days a week...
 


Posted By: DBlank
Date Posted: 13 Apr 2010 at 4:52am
this does not quite take into account the completion by 8:02 the next morning but I hope it gets you on a track that works


Posted By: Mendoza
Date Posted: 13 Apr 2010 at 5:08am
Thank you so much for your time DBlank! I will give this a go and let you know how I get on!  Have a good day!
 
DBlank, I managed to get you code working with a few tweaks which is wonderful.  Now I just got to work on specifying our working week, Mon-Fri.
 
Once again, thank you for your help.


Posted By: DBlank
Date Posted: 13 Apr 2010 at 5:28am
Just work through all your possible conditions of when somehting starts and ends (including going over 24 hours or week ends) and apply that logic in the if-then-else-if....
If you run into problems let me know.


Posted By: Mendoza
Date Posted: 13 Apr 2010 at 5:30am
Will do!  Thanks again!



Print Page | Close Window