Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula when field is null Post Reply Post New Topic
Author Message
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Topic: Formula when field is null
     Posted: 28 Nov 2012 at 1:59am
Hello Crystal guru's,
 
I have the following question:
 
i have a report with different columns.
column A, B, C, D and E
 
some vaulue of column B are 0,00.
Now I want to make a display string in Column C that when column B = 0,00 or 0 then I want to show the value of column A in Column B.
 
I've tried different formulas but they don't work:
example of formula i tried:
if {column B} = 0 then {column C} = {column A} else {column C}
 
Thank you in advance.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 28 Nov 2012 at 2:24am
Hi
 
Try this
 
Stringvar x;
If {Column B} = 0  Then
x:={Column A}
else
x:={Column C}
Thanks,
Sastry
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 28 Nov 2012 at 2:39am
I am a little confused, are you working with a null value or an actual '0' string, if so.

the formula would probably need to be
-----------
local stringvar x;
If {Column B} in ['0','00'] Then
x:={Column A}
else
x:={Column C};

x

------------

however, I am confused what null has to do with this;

also, this statement doesnt make much sense

Now I want to make a display string in Column C that when column B = 0,00 or 0 then I want to show the value of column A in Column B.

if column B = '0' or '00' then show the value of column A in column B. I don't see the relation to Column C.



Edited by comatt1 - 28 Nov 2012 at 2:43am
IP IP Logged
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Posted: 28 Nov 2012 at 3:01am

Thank you for the quick reply but I get the following error:

 
A string is required here.
 
the error is highlited on line 3   x:={Column A}
it is a datefield, i don't know if that matters.
 
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 28 Nov 2012 at 5:27am
Yes it matters.  The question then is {Column C} also a datefield?  If so then change the local stringvar x; to local datevar x;  If {Column C} is a string then change x:={Column A} to x:=totext({Column A})  (you may need to use the optional parameter for totext to format the date the way you need it).

The bottom line, x's data type has to match whatever you are assigning it to.

I hope this helps.
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