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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating the difference between two numbers in a group 2

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
I have a group that returns several records.
I need to include a field that shows the increment between each value (the difference between one value and the previous record's value)


there is no difference function in the Running Total fields.
can anyone suggest anything?
 
Try the following formula"

No OnFirstRecord;
{Fieldname}-Previous({Fieldname})

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Slight correction, that first line of code should be "Not OnFirstRecord;"

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
hi, I have tried this, but when I check the formula I get the error "remaining text does not appear to be part of the formula"

any idas why?
 
great!! that works
thank you very much!
 
one other thing though!

how can I reset it at the start of each group?
 
You wil probably need 2 formulas to accomplish this

Place the difference formula on the details line
Code:
//@Difference
WhilePrintingRecords;

BooleanVar Reset;
NumberVar Difference ;

If not Reset Then
    Difference := {MyTable.MyRecord} - Previous({MyTable.MyRecord})
Else
    Difference := 0;

Reset := false;

Difference

place the reset formula in the group header

Code:
//@Reset
WhilePrintingRecords;

BooleanVar Reset := True;

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
thank you for your help.

how can I supress the result if it is equal to '0'?

 
right click the field, choose format and click on the "suppress if zero" checkbox.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
i don't have a supress if zero checkbox.
I have a 'supress if duplicated'.

can I enter the supress command in the formula editor somehow?
 
I don't have the suppress if zero either but I could have sworn this was available.

To the right of the suppress checkbox is a button labeled X-2. Click on it and enter the formula:

Code:
{YourField}=0



Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
one other thing - which is not really part of the main thread.
how can I stop a group being displayed over two pages?

 
have a look in Group Options 'Keep Group Together'

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
that is already checked and yet some of my groups records are going onto a second page...


 
If the group contains more records than you have space for on 1 page then crystla has to start a 2nd page, There is no formatting available for a 'Fit to Page'



Gary Parker
MIS Data Analyst
Manchester, England
 
none of my groups are over 4 records long and spaced closed together, yet some of them DO go over the page...
 
These should break to another page, how else is the report formatted ? i.e. how many groups are there, what options are set for these ? what sections do you have on the report ? any sections suppressed ?



Gary Parker
MIS Data Analyst
Manchester, England
 
hmmm, I have tried unsupressing my report footer and group footer etc, and all sections have 'keep together' checked!

I suppose I can live with it.

I should get back to the main thread now... :)

someone has just asked me if I could add another couple of columns to the report.
for soem reason I can't summarise the 'difference' formula that was mentioned above. (it isn't diaplayed in the report fields) - and yet I need to include a column that SUMS the results of the difference for each row, and another column to display the percentage change from the first row.

Is any of this possible?

like I said I have tried a Running Total field but cannot see the field in the list...
 
To access the "Suppress if Zero" you need to go to the number tab and choose the Customize button.

Mike
 
thanks Mike.
I've already typed a formula next to the supress checkbox - but I will remember that for the future..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top