Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula question Post Reply Post New Topic
Author Message
AndyLeates
Newbie
Newbie


Joined: 05 Oct 2011
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote AndyLeates Replybullet Topic: Formula question
    Posted: 03 Apr 2012 at 4:43am
Afternoon
 
I am reporting on an IT Service Desk. My report is in two groups, Incidents and Service Requests.
 
I wish to obtain the average fix time for Incidents.
 
In the details section, i have the formula
 
@fixtime
{vTASKS_BROWSE.CLSDDATE}-{vTASKS_BROWSE.OPENDATE}
 
and in the group footer I have
 
@AvgResTime
 
For some reason, the result of this formula is always the same for each group, and I don't understand why.
 
Many thanks for your help.
 
Andy
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Apr 2012 at 4:48am
sum(field) is the summing all values for the report
you need to add teh group condition to your summary to get the value for each grouping
sum(field,groupfield)
 
(sum(fixtime,table.groupfield))/(count(fixtime,table.groupfield))
 
 
IP IP Logged
AndyLeates
Newbie
Newbie


Joined: 05 Oct 2011
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote AndyLeates Replybullet Posted: 03 Apr 2012 at 4:58am
Brilliant, that has worked. Thank you, no doubt a newb.
 
It has raised another question though (cheeky, I know)
 
@AvgResTime now has two values, one for each group.
 
How would I select one of these values to work with? i.e. there is text in my report that says:
 
"The average resolution time for Incidents is " & @AvgResTime
 
By default, it seems to use the first group value, which is handy. But what if I wanted to use the second value?
 
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 03 Apr 2012 at 5:17am

The field will automatically pick up the first entry in a list, so it will always return the value for the first group.

If you manually wanted to change the reult in that field you create another formula where you type which group you want to sum;
 
(sum(fixtime,table.groupfield,"Name of group"))/(count(fixtime,table.groupfield,"Name of group"))
 
Regards,
Ryan.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Apr 2012 at 5:24am

I was afraid that might be the next question Wink

I would recommend deciding how you want your end result to appear and then working on a solution from there.
 
The "by default it grabs the first record" might be misleading. MY guess is you placed this in the report header which will only evaluate for the first row which in this case is equivalent to the first group. If you place it in the report footer you would get the last row (or equivalent of the last group).
 
A few solutions are:
Create specific running totals to evaluate for only specific records.
Create variable formuals to do the same thing as the RTs.
use a Cross tab. The beauty of a crosstab is that it expands as your gros expand where as the RTs or variable formulas need to be created per group.
 
However I would rework this entirely to be a little more efficient and give you more flexibility.
It appears you are looking at average days for you evaluation.
 
I prefer using datediff to get the value
datediff('d',{vTASKS_BROWSE.OPENDATE},{vTASKS_BROWSE.CLSDDATE})
Now just insert an summary of this field as an average at the group level.
You can also use this in a crosstab or chart in a the report header.
it will end up looking like
average(field,group)
 
if you really want to control this for a sepecifc value use a running total
name=av_Inc
type=average
evaluate=use a formula
table.field='incident' (however you identify an incident row)
reset=never
place in report footer
RT's do not work in headers.
 
if it must be in a header there is another trick. Just let me know if you need it.
IP IP Logged
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.000 seconds.