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

Referring to a field in the previous record or next record 1

Status
Not open for further replies.

JerryJay

Technical User
Jan 27, 2006
24
US
New to Crystal but I ma getting the hang of things.

I need to calculate a %change in weight from a column of information based upon the paramenters I have set. See example of data output

Lakewood Gash Lillian 12/5/2005 106.00
Lakewood Greene Marvin 12/5/2005 113.00
Lakewood Streater Sammy 168.00
Lakewood McBride Mary 12/5/2005 110.00
Lakewood Ruppert Brenda 12/5/2005 125.00
Lakewood Arana Liliana 12/5/2005 185.00

I would like to insert a formula in the last column which calculates the %Change. I do not know hao to referenc the previous field value. Can anyone help?
 
Try something like:

if onfirstrecord or
{table.groupfield} <> previous({table.groupfield}) then 0 else
({table.weight}-previous({table.weight})) % previous({table.weight})

If you aren't grouping, then remove the second line. Then place the formula in the detail section and click on the percent icon in the toolbar to get the percent sign.

-LB
 
Thanks for the information. This gives a push in the right direction. I will let you know if i get it working. Thanks again
 
Actually, with no group field, it would be:

if onfirstrecord then 0 else
({table.weight}-previous({table.weight})) % previous({table.weight})

-LB
 
LB,

Why do I keep getting a No Division by 0 error?
 
You either have a weight that is null and you have set "convert null values to default" in report options, or a weight that is null. You could make sure the convert nulls to default is checked and then change the formula to:

if onfirstrecord or
{table.groupfield} <> previous({table.groupfield}) then 0 else //remove if no groups
if previous({table.weight}) = 0 and
{table.weight} <> 0 then 100 else
if previous({table.weight}) = 0 and
{table.weight} = 0 then 0 else
({table.weight}-previous({table.weight})) % previous({table.weight})

-LB
 
LB,

Thanks for all of the help!!!!!!!!!!!!!!!!!11
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top