Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Display selected numbers as a negative Post Reply Post New Topic
Author Message
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Topic: Display selected numbers as a negative
     Posted: 02 Feb 2015 at 5:00pm
I've had an extended absence from Crystal and, it appears I'm a bit rusty. I'm using Crystal XI to write a reasonably simple report for our finance dept of gl transactions and have run into a problem. The report is;

cost_code_cr    cost_code_dr    movement_value

10-1130                            110.00
                   10-2085        110.00
10-1030                            350.00
                   10-2085        350.00

I want the 'movement value' in the 'cost code cr' line to display as a negative. I've written this formula;

if isnull ({gl_trans.cost_code_dr}) then ({gl_trans.movement_value}*-1)
else {gl_trans.movement_value};

But it has no effect on the report. Any ideas??

The 'cost code dr' & 'cost code cr' fields are both strings and the 'movement value' field is a number.

Thankyou in advance
IP IP Logged
Vimal Nair
Newbie
Newbie
Avatar

Joined: 29 Dec 2014
Location: United Arab Emirates
Online Status: Offline
Posts: 26
Quote Vimal Nair Replybullet Posted: 02 Feb 2015 at 7:15pm
If its just for the display purpose, Select format field. In Negative Tab select -123. and below select the radio button Reverse sign for display.

Please note. In case of -ve database values , it will be displayed as absolute value of the number.
Born To Live
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Feb 2015 at 3:35am
are you displaying the formula field in place of the movement value field?
Formula's do not alter the original data.
also start with a little dubugging and place a formual field on the detail section as
isnull ({gl_trans.cost_code_dr})
and see if you get the True False values you expect on each line.
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 03 Feb 2015 at 12:05pm
I had tried that and it displays all the values in 'movement value' as a negative. I only want a negative on the lines that has 'cost code cr'.
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 03 Feb 2015 at 12:13pm
At the moment I have the formula field as well as movement value on the report to see if the formula worked.
I've also done some debugging and it returns false for all lines.
The movement value field is only one field, not two. I need the report to look like this for display purposes, and I'm going to need some totals at the end as well.

cost_code_cr      cost_code_dr   movement_value

10-1130                            -110.00
                    10-2085        110.00
10-1030                            -350.00
                    10-2085        350.00

Thanks very much



Edited by duffey01 - 03 Feb 2015 at 12:15pm
IP IP Logged
Vimal Nair
Newbie
Newbie
Avatar

Joined: 29 Dec 2014
Location: United Arab Emirates
Online Status: Offline
Posts: 26
Quote Vimal Nair Replybullet Posted: 03 Feb 2015 at 6:31pm
I thought its a simple display. My bad understanding.

Try This.

If Not Isnull({gl_trans.cost_code_cr}) Or ({gl_trans.cost_code_cr})<>""
Then ({gl_trans.movement_value}*-1)
Else ({gl_trans.cost_code_dr})

Put this formula in Details to display the -ve values.
Born To Live
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Feb 2015 at 4:37am

Hopefully Vimal's formula resolves this for you.

Since your debugging was displaying False on every line this lets you know that the gl_trans.cost_code_dr is never NULL and is more likely an empty string. Vimal's ;ast post addresses this.
I have also seen this where you need to trim the field when comparing it to an empty string as it may have spaces in it.
again you can debug to see it by using a formula as
{gl_trans.cost_code_cr} <> ""
place it on the detail row and see if you get True False where expected.
you may need to try
TRIM({gl_trans.cost_code_cr})<>""
if it has any spaces in the field
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 04 Feb 2015 at 1:02pm
No good :( It displayed everything as a negative again. But DBlank's helped.

Thank you very much
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 04 Feb 2015 at 1:08pm
Thanks DBlank, you've done it again!

I debugged it using your formula and got the True/False results, then used that in a if/then/else formula to display the negatives where I wanted them.

Thank you so much. I was pretty sure if I could get a Boolean to display I would be on my way, but I never would have thought of an 'empty string'.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum