# Crystal Formula

Hello everybody,
I have the below crystal formula:

if {Billing.CCID}= 'MNGED PER DIEM' or {Billing.CCID}= 'MED A PER DIEM' then

local numbervar billamount := {Billing.BillAmt}
else
if IsNull({Billing.CCID}) then
local numbervar billamount := 0.00;

The formula is displaying the data for medaperdiem or mngedperdiem but the second condition is not getting evaluated.Its not displaying 0.00

###### Who is Participating?

DeveloperCommented:
Crystal requires the evaluation of null FIRST.

Try this:

local numbervar billamount;  //this declares the local variable
if isnull({Billing.CCID})  then billamount:=0
else if ({Billing.CCID}= 'MNGED PER DIEM' or {Billing.CCID}= 'MED A PER DIEM' ) then
billamount := {Billing.BillAmt};
0

DeveloperCommented:
you might want to consider what should happen with billamount if {Billing.CCID} is not null, not 'MNGED PER DIEM' and not 'MED A PER DIEM'.  in other words, make sure you don't need a default value for billamount.  you could do one of the following:

local numbervar billamount:=0;  //this declares the local variable and sets default value to zero
if isnull({Billing.CCID})  then billamount:=0
else if ({Billing.CCID}= 'MNGED PER DIEM' or {Billing.CCID}= 'MED A PER DIEM' ) then
billamount := {Billing.BillAmt};

-------------------
or
------------------
local numbervar billamount;  //this declares the local variable
if isnull({Billing.CCID})  then billamount:=0
else if ({Billing.CCID}= 'MNGED PER DIEM' or {Billing.CCID}= 'MED A PER DIEM' ) then
billamount := {Billing.BillAmt}
else billamount:=0;  //if all else fails, set billamount to 0
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.