cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying Positive/Negative numbers from a formula

Former Member
0 Kudos

I have the following formula that looks similar to this..

(Field1) - (Field2)

when field 1 is smaller then field 2 we know that the number will be a negative and the report will print a negative sign in front of the number.

Now here is the question, say (Field1) was equal to 10, and (Field2) was equal to 9 the formula would look like

(10) - (9)

and the report would print a positive 1. Is there anyway to format the formula to display a Positive sign in front of the number if it is positive, and a negative in front of the number if it is negative?

Thanks everyone for your help!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Levi

You can modify your formula like this...

numbervar a:=0;

a:=({Field 1})-({Field 2});

if a >= 0 then

"+" & a else "-" & a;

Hope this helps...

Regards

Ankeet

Former Member
0 Kudos

Yes, that formula works for me. I had to slightly modify the formula because it was printing two negative signs on ther report instead of one. I think that may have been due to how I had my number formatting options set in Crystal.

Here is the original formula:

numbervar a:=0;

a:=(Field1)-(Field2);

if a >= 0 then

"+" & (a) else " -" & (a);

Then I changed it to be:

numbervar a:=0;

a:=({@JM_ClaimAmt})-({Reconciliation_GetReport;1.UPCClaimAmt});

if a >= 0 then

// Took out the negative sign here so it would not show negative twice.

"+" & (a) else " " & (a);

It works now, I'm happy

Answers (0)