Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Selection within a Formula Post Reply Post New Topic
Author Message
bwagner
Newbie
Newbie


Joined: 16 Nov 2007
Online Status: Offline
Posts: 4
Quote bwagner Replybullet Topic: Selection within a Formula
    Posted: 15 May 2008 at 2:05pm

I'm working on some reporting for a call center and I'm trying to write a report for the logged in time of our agents.  Problem is, they are on anywhere from 2-7 skillsets, and sometimes they change.  Our SQL server records time logged in for each skillset and adds it together, so if they are on 3 skillsets, and logged in for 1 hour, it returns logged in time as 3 hours.

I had tried doing a distinctCount, but if people change skillsets during the period I'm running it all gets thrown in a loop.  So, there is one skillset that everyone has as a base skillset, I'm trying to figure out how to best select that skillset, but within the formula for logged in time only.  Here is what I have so far.

NumberVar loggedon1;
Select {t_Skill_Group.SkillTargetID} = 5000;
loggedon1:=Sum ({t_Agent_Skill_Group_Half_Hour.LoggedOnTimeToHalf},{t_Agent.PersonID});
 
5000, is the default skillset.  Is there a different way I should be selecting the target ID?  I hope this makes sense to someone.
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 16 May 2008 at 5:26am
Yes.  It is a pretty classic problem within Crystal.  There are a couple possible solutions.

One is to group your report based on skill set.  You can then run summaries on just the current group.  This is the simplest solution, but frequently doesn't meet other demands of the report.

Another is to do a running total.  You can do a running total to add the hours if the skill set is 5000, and add 0 otherwise.  This has the downside that it is tricky at best to reference a running total with any other formulas.  So, it pretty much is only useful if you just want to display the total in the footer.

Another option is to use a formula to zero out any values you don't want to see.  So, put a formula in the details section that looks like:

WhileReadingRecords

IF {t_Skill_Group.SkillTargetID} = 5000 THEN
    {t_Agent_Skill_Group_Half_Hour.LoggedOnTimeToHalf}
ELSE
    0

You can then do your SUM on this formula, and the zero values are effectively ignored.  Note that this does not affect COUNT, and skews AVERAGE.

The most complex and flexible solution is to use a global variable.  Create a formula that looks like:

WhileReadingRecords

Global NumberVar loggedon1;

IF {t_Skill_Group.SkillTargetID} = 5000 THEN
    loggedon1 := loggedon1 + {t_Agent_Skill_Group_Half_Hour.LoggedOnTimeToHalf}

Then, you can just write a formula to return the final value of loggedon1 in the report footer.  This is typically used for more complex scenarios than yours.  Also, note that, as written, this formula does not distinguish between Agents.  I'll leave that as an exercise for the reader.  Wink


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.031 seconds.