Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Row Count within 48 hours. Post Reply Post New Topic
Page  of 2 Next >>
Author Message
hegazy
Newbie
Newbie


Joined: 18 Dec 2009
Online Status: Offline
Posts: 11
Quote hegazy Replybullet Topic: Row Count within 48 hours.
    Posted: 18 Dec 2009 at 8:49am
Good morning everyone. For the past few days I've been reading this site trying to understand crystal reports as this application is still new to me.

I am trying to get a number count on the number of tickets opened within the 48 hours. I have been unsuccessful in getting a ticket count.

So I have:

if {Incident.LastStatus} in ["Active", "Waiting", "Logged"] then
if {Incident.CreatedDateTime} < currentdate and minute({Incident.CreatedDateTime}) >= 2880   then
    
      count ({Incident.LastStatus})

I am not sure if the minute() function is used properly here.

Thank you.



IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Dec 2009 at 9:35am
I think I would just use a dateadd of minutes here:
 
{Incident.CreatedDateTime} in dateadd('n',-2880,currentdatetime) to currentdatetime


Edited by DBlank - 18 Dec 2009 at 10:00am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Dec 2009 at 9:59am
As for counting them here are 3 main ways (assuming you do not have duplicate data rows that you have not mentioned):
1. Create a formula field to make a 1 or 0 based on your critieria then sum that formula field:
Formula sample...if {Incident.LastStatus} in ["Active", "Waiting", "Logged"] and {Incident.CreatedDateTime} in dateadd('n',-2880,currentdatetime) to currentdatetime then 1 else 0
 
2. Use a Running Total to conditionally count the records
Field to summarize = incidentID (or {Incident.CreatedDateTime} if you want)
Type of Summary = Count
Evaluate= Use a formula
Enter the formula {Incident.LastStatus} in ["Active", "Waiting", "Logged"] and {Incident.CreatedDateTime} in dateadd('n',-2880,currentdatetime) to currentdatetime
Reset= Never
Place on report footer to see total.
 
3. Use variable formula to do the same thing as #2


Edited by DBlank - 18 Dec 2009 at 10:05am
IP IP Logged
hegazy
Newbie
Newbie


Joined: 18 Dec 2009
Online Status: Offline
Posts: 11
Quote hegazy Replybullet Posted: 18 Dec 2009 at 10:33am
Thank you very much for the quick response. I didn't know that I can use dateadd() function for this or running totals.

Thanks again!
IP IP Logged
hegazy
Newbie
Newbie


Joined: 18 Dec 2009
Online Status: Offline
Posts: 11
Quote hegazy Replybullet Posted: 23 Dec 2009 at 6:27am
Another question:

Would the dateadd() be the same for an overall date meaning I have a fixed date 1/1/2009(beginning of the year) to the currentdatetime?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Dec 2009 at 7:47am
Do you mean you want to use a select statement to find any records with dates in this year?
You can use the dateadd() or dateserial() or the easiest would be
{table.datefield} in yeartodate
IP IP Logged
hegazy
Newbie
Newbie


Joined: 18 Dec 2009
Online Status: Offline
Posts: 11
Quote hegazy Replybullet Posted: 23 Dec 2009 at 8:02am
Originally posted by DBlank

Do you mean you want to use a select statement to find any records with dates in this year?
You can use the dateadd() or dateserial() or the easiest would be

{table.datefield} in yeartodate


That is correct. When I put the running total (named overall) I get 0 entries (Using code below):

{Incident.Source} in ["Logged", "Active","Waiting"] and
{Incident.CreatedDateTime} in YearToDate

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Dec 2009 at 8:05am
Hmmm.
Try:
{Incident.Source} in ["Logged", "Active","Waiting"] and
{Incident.CreatedDateTime} in datetime(year(currentdate),1,1,0,0,0) to currentdatetime
IP IP Logged
hegazy
Newbie
Newbie


Joined: 18 Dec 2009
Online Status: Offline
Posts: 11
Quote hegazy Replybullet Posted: 23 Dec 2009 at 9:12am
Hmmm...I'm still receiving 0 as a total result. Why would I be able to retrieve data for the 48 hours but not for the beginning of the year?

Also, may you explain to me what the 1's and 0's are for?

{Incident.CreatedDateTime} in datetime(year(currentdate),1,1,0,0,0)

Thank you.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Dec 2009 at 9:25am
Datetime(yyyy,month,day,hour,minute,second)...
1 and 0 are (in this case) to give you jan 1 at midnight...
month(1=jan), day(1=first),hours(0=midnight), minutes(0=none) and seconds(0=none)
 
Where exactly are you using this formula (select expert, formula, running total?)
 
You can test a it by creating it as a formula field and placing it on the detail section. It will place a TRUE if the condition is met and a FALSE if not.
Break your condition into 2 pieces and test each one to see where it is breaking.
Formula 1= {Incident.Source} in ["Logged", "Active","Waiting"]
Place it next to the SOurce field on details to check it
Formula 2= {Incident.CreatedDateTime} in datetime(year(currentdate),1,1,0,0,0) to currentdatetime
 Place it next to the Createdatetime field on details to check it
 
What is working and what is not?
 


Edited by DBlank - 23 Dec 2009 at 9:27am
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.