In SQL, this is my working formula:
IF ({BTDetail.UnitFlag} = \'T\') THEN (IF ({BTDetail.TransType} = \'C\') THEN {BTDetail.Qty}*{BTDetail.PerCode}*-1 EL