[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# How do I use the correct sum function in crystal report formula editor

Posted on 2004-11-18
Medium Priority
7,254 Views
I have three fields I developed with formula editor name #countd ,#countd2, and #countd3 how do I use the sum() function to add a field in my report to display the total.
0
Question by:tupac1979
• 2

LVL 101

Expert Comment

ID: 12617823
HAven't used the sum function.

What is wrong with

sum(#countd ,#countd2, #countd3)

or

sum({#countd} ,{#countd2}, {#countd3})

mlmcc
0

LVL 28

Expert Comment

ID: 12617829
Judging by the fact that all 3 fields have a "#" sign in front of the name, it looks like you have created Running Totals.
Running Totals are evaluated while the records are printing and the sum function is evaluated while the records are read so you cannot insert a summary on a running total.
A running total can be set up to sum a certain set of records if you need it to be.
Depending on what your running totals are doing, we may be able to set you up with some simple formulas that will allow for you to insert a summary off of it.
Can you post what your 3 running totals are doing? (field, summary type, how it is evaluating, and when it is resetting)
0

Author Comment

ID: 12617922
They are running totals and they are setup like this
#count1
Evaluating : using the formula

Resetting at
On change at group - GROUP1# ADMSTAT.AGENCY

#count2
Evaluating : using the formula

Resetting at
On change at group - GROUP1# ADMSTAT.AGENCY

Evaluating : using the formula

Resetting at
On change at group - GROUP1# ADMSTAT.AGENCY

The purpose of these fields is to display the total number of duplicate Patid's and then I want the total number of duplicates

0

LVL 28

Accepted Solution

bdreed35 earned 500 total points
ID: 12618006
Since you are using the Previous and Next functions, you won't be able to use the sum function.
You have 2 methods to accomplish this.

ONE -
Create a duplicate of each running total and ONLY change the reset to Never.
Place each RT in the report footer, and your done.

TWO-
Create a formula to accumulate the values in the GROUP1# ADMSTAT.AGENCY footer, and then 3 formulas to display the totals at the end.

//@Accum
whileprintingrecords;
numbervar count1 := count1 + {#count1};
numbervar count2 := count2 + {#count2};
numbervar count3 := count3 + {#count3};
""

Place the above formula in the GROUP1# ADMSTAT.AGENCY group footer and suppress it.

//@DisplayCount1
whileprintingrecords;
numbervar count1;

//@DisplayCount2
whileprintingrecords;
numbervar count2;

//@DisplayCount3
whileprintingrecords;
numbervar count3;

Place the above three formulas in the report footer.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…