Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Un-sumamble Number....why?

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

Below is my code from a field that I want to sum. But when ever I attempt to create a new field to do the summing, all i get is an error message saying field cannot be summarised

if PreviousIsNull ({VW_EVT_AGENT_PERF.EAP_STAFF}) OR
Previous ({VW_EVT_AGENT_PERF.EAP_STAFF}) <> {VW_EVT_AGENT_PERF.EAP_STAFF} OR
Previous ({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) <> {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}
then
if( Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_REASON_TEXT}) = &quot;BREAK&quot; )then
RIDTSToSeconds({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) - RIDTSToSeconds(Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_TIME}))
else
0

Why is this the case?
Hope someone can help


TIA
Steven
 
You can't do summary functions on formulas that contain other summary functions OR use the Previous(), PreviousIsNull(), Next(), or NexstIsNull() functions.

~Brian
 
DOH!

IS there a solution or work around?

I need to use previous as I take 1 signout time from another sign in time to give me the length the agent was signed out.

But I need to sum these periods over the day.....can it or anything like it be done??/

TIA

Steven
 
Code:
WhilePrintingRecords;
NumberVar MyCounter := My Counter + 
if  PreviousIsNull ({VW_EVT_AGENT_PERF.EAP_STAFF}) OR
    Previous ({VW_EVT_AGENT_PERF.EAP_STAFF}) <> {VW_EVT_AGENT_PERF.EAP_STAFF}  OR
        Previous ({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) <> {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME} 
            then
                if( Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_REASON_TEXT}) = &quot;BREAK&quot; )then 
                     RIDTSToSeconds({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) -  RIDTSToSeconds(Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_TIME}))
                else
                    0
should do it.

Place a call to MyCounter to display the summed value.

If you use this approach, remember to reset the value of MyCounter if and when you want to reset the summation.

All the best,

Naith
 
You can do some creative things with variables.

Off the top of my head, you could create a formula that would have 2 variable, 1 for current value, and 1 for the previous value.

Something like this might work for you but you will have to give it a try:
Code:
stringVar Previous_EAP_STAFF;
stringVar Current_EAP_STAFF;
stringVar Previous_EAP_SIGN_IN_TIME;
stringVar Current_EAP_SIGN_IN_TIME;
stringVar Previous_EAP_SIGN_OUT_REASON_TEXT;
stringVar Current_EAP_SIGN_OUT_REASON_TEXT;


Previous_EAP_STAFF := Current_EAP_STAFF;
Current_EAP_STAFF := {VW_EVT_AGENT_PERF.EAP_STAFF};

Previous_EAP_SIGN_IN_TIME := Current_EAP_SIGN_IN_TIME;
Current_EAP_SIGN_IN_TIME := {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME};

Previous_EAP_SIGN_OUT_REASON_TEXT := Current_EAP_SIGN_OUT_REASON_TEXT;
Current_EAP_SIGN_OUT_REASON_TEXT := {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME};

if  IsNull (Previous_EAP_STAFF) OR
    Previous_EAP_STAFF <> Current_EAP_STAFF  OR
        Previous_EAP_SIGN_IN_TIME <> Current_EAP_SIGN_IN_TIME 
            then
                if( Previous_EAP_SIGN_OUT_REASON_TEXT = &quot;BREAK&quot; )then 
                     RIDTSToSeconds({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) -  RIDTSToSeconds(Previous_EAP_SIGN_IN_TIME)
                else
                    0

~Brian
 
very simply...create a 3 formula sum

In the report header (or a main group header if this sum is done more than once place this formula

//@Init (suppressed)
whilePrintingRecords;

if not inRepeatedGroupHeader then
numbervar total := 0
else
0;

then your main calc formula

//@Calc

whilePrintingRecords;
numbervar total;
numbervar temp;

if PreviousIsNull ({VW_EVT_AGENT_PERF.EAP_STAFF}) OR
Previous ({VW_EVT_AGENT_PERF.EAP_STAFF}) <> {VW_EVT_AGENT_PERF.EAP_STAFF} OR
Previous ({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) <> {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}
then
(
if Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_REASON_TEXT}) = &quot;BREAK&quot; then
temp := RIDTSToSeconds({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) - RIDTSToSeconds(Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_TIME}))
else
temp := 0
)
else
temp := 0;

total := total + temp;

temp;

//it is done this way so that the individula canculation will still be displayed.

to display the sum in a footer somewhere place the formula

//@DisplaySum

whilePrintingRecords;
numbervar total;

total;



Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Ngolem,

Thanks for your help.

The first part of the code.....where will I put it?/

In a field or in a section??? If its in a section what will i attach the cod eto?


Thanks


Steven
 
if you mean where I put

//@formula name

This is not really part of the formula...this is just the name itself made as a comment statement.

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Sorry Jim,

I must sound stupid....but you said &quot;In the report header (or a main...&quot;

Where do I put this code, you cant just put it in a report header can you?

Sorry for bugging you.


Cheers

Steven
 
hahaha...no problem

No you don't type this into the report header directly you create formulas that are then placed in their respective sections

I'll go over this again

create a formula called &quot;Init&quot; (no quotes)...it will appear in Crystal as @Init.

In this case I will assume the report is being run once so the Init formula would be put in the report header and suppressed...if the report is repeated over and over again use the formula I wrote earlier

//@Init (suppressed)
whilePrintingRecords;

numbervar total := 0;


then your main &quot;Calc&quot; formula is placed in the Detail section and is also suppressed unless you want to view the result.

//@Calc

whilePrintingRecords;
numbervar total;
numbervar temp;

if PreviousIsNull ({VW_EVT_AGENT_PERF.EAP_STAFF}) OR
Previous ({VW_EVT_AGENT_PERF.EAP_STAFF}) <> {VW_EVT_AGENT_PERF.EAP_STAFF} OR
Previous ({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) <> {VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}
then
(
if Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_REASON_TEXT}) = &quot;BREAK&quot; then
temp := RIDTSToSeconds({VW_EVT_AGENT_PERF.EAP_SIGN_IN_TIME}) - RIDTSToSeconds(Previous({VW_EVT_AGENT_PERF.EAP_SIGN_OUT_TIME}))
else
temp := 0
)
else
temp := 0;

total := total + temp;

temp;

//it is done this way so that the individula canculation will still be displayed if you want them to be.

to display the sum, place this formula in the report footer

//@DisplaySum

whilePrintingRecords;
numbervar total;

total;


Hope this helps you


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top