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

Reset a Percentage Formula Field on Group Change

Status
Not open for further replies.

drivr

Programmer
Aug 24, 2000
5
CA
I am using CR v7 - database driver - PdBXBSE.DLL (xbase)
I have a report where a have to take numbers and show a percentage change from month to month. However when the location changes, i want to reset the variable So that it starts from 0 again. I am using 3 formulas, all using a numbervar - one formula to do the calc. in the details and is suppressed;

WhilePrintingRecords;
numbervar ao:={cert_mast.CONTRIB} % previous({cert_mast.CONTRIB})

another in the group header used to reset the variable;

WhilePrintingRecords;
numbervar ao:=0;

and one in details that displays the numbervar.

Whileprintingrecords;
numbervar ao;

ie.

January 9 0.00%
February 19 211.11%
March 18 94.74%

and so on.
What am I doing wrong?

thanks in advance,
jds
 
The "difference" would typically be shown by a slight modification to your formula:
WhilePrintingRecords;
numbervar ao:=1-({cert_mast.CONTRIB} % previous({cert_mast.CONTRIB}))

January 9 100.00%
February 19 111.11%
March 18 -5.26%

If you wanted to get a difference value for Jan, you could get the previous Dec value, but suppress the display of it.
Is that the issue?

 
Thanks for the quick reply - but the issue is that for the first location the data is correct - however even though I have reset the variable, the data continues to evaluate a percentage on the previous record.

ie.

Office 1
...
MTH # %
June 14 77.78%
July 7 50.00%

Office 2
MTH # %
Jan 20 285.71%

and so on. I need the january percentage to start at 0 (or actually 100%) again. Thanks so much for your help,
jds
 

whileprintingrecords ;
numbervar ao ;
If year(your date) = previous(your date) then
ao :=({cert_mast.CONTRIB} % previous({cert_mast.CONTRIB})
Else
ao := 1%1
 
You could do the following...
1. Remove the ao=0 from the group header - this is being overwritten when the detail section prints.
2. Instead of just setting the variable ao to the field, check to see if the field that you are grouping on has changed, by this:
numberVar ao ;
if RecordNumber=1 then
ao:=0
else
if GroupNumber = 1 then
ao:=Previous ({TillReport.Quantity})
else
if {TillReport.Store}<>Previous ({TillReport.Store}) then
ao:=0
else
ao:=Previous ({TillReport.Quantity})

then you are not limited to checking Jan - Dec. It would also work for checking Apr - Mar (financial years) for example.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top