Hi I have created a formula (@quantity) to set duplicates to 0 as per below

Code:
if onfirstrecord then {BKGDTL.BTEQTY} else
if {BKGDTL.BTEQTY}=previous({BKGDTL.BTEQTY})and
{BKGCOM.BCBKGN}=previous({BKGCOM.BCBKGN})and
{BKGCNT.BKITEM}=previous({BKGCNT.BKITEM}) then
0 else {BKGDTL.BTEQTY}
In the report footer I would like to summarise the values (@20Dry)

Code:
IF {BKGCNT.BKESIZ}= 20 and 
{BKGCNT.BKETYP}=["DC","DH","FP","HC","HW","OT"]then 
numbervar x:=x +{@quantity}
the final number I get is 41 which appears to be how many times the field appears and not the sum of the values.... when I try to use sum it says field cannot be summarized.... Any ideas on how to summarize the values reflected by @quantity would be greatly appreciated.