Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: Case statement as a formula Post Reply Post New Topic
Author Message
brent21090
Newbie
Newbie


Joined: 20 Apr 2009
Online Status: Offline
Posts: 31
Quote brent21090 Replybullet Topic: Case statement as a formula
    Posted: 29 May 2009 at 5:50am
I am evaluating the following as a formula in Crystal XI and my formula is not working.  Any help appreciated.
 
case {fieldname} = 1
"A"
Case {fieldname} = 0
"B"
Case {fieldname} = 1
"C"
Case {fieldname} = 3
"Closed"
Case {fieldname} = 4
"D"
End case
 
Thxs
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 29 May 2009 at 6:28am
Hi
 
Select {fieldname}
Case  1 :
"A"
Case  0 :
"B"
Case  1 :
"C"
Case  3 :
"Closed"
Case  4 :
"D"
Default :
"default"
cheers
Rahul


Edited by rahulwalawalkar - 29 May 2009 at 6:28am
IP IP Logged
brent21090
Newbie
Newbie


Joined: 20 Apr 2009
Online Status: Offline
Posts: 31
Quote brent21090 Replybullet Posted: 29 May 2009 at 6:38am
That worked. 
Now what does word "Default:" mean at the end of the statement?
Thanks Raul
 
Lucy
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 29 May 2009 at 6:46am

Hi Lucy,

Default :
"default"
 
is used to return value ,if none of the conditions checked in the case statement retruns any value it will display text "default" ,you can change to any text you want.if it is not coded it will return empty string
 
Cheers
Rahul
IP IP Logged
brent21090
Newbie
Newbie


Joined: 20 Apr 2009
Online Status: Offline
Posts: 31
Quote brent21090 Replybullet Posted: 29 May 2009 at 6:48am
Thank you
IP IP Logged
kathuriap
Newbie
Newbie


Joined: 23 Sep 2010
Online Status: Offline
Posts: 2
Quote kathuriap Replybullet Posted: 23 Sep 2010 at 11:44pm
Hi , I am stuck with this issue in my reports. I would be very grateful if someone could suggest me where am doing it wrong .
I have a cross tab object in my report where I have multiple rows for Currency and Date and and Amount as the column. There are summarized field for the amount fields.

So its something like this-
                                               Amount                 Total

BHD       22/07/2009              12345.65                12345.65
             23/07/2009               6444.55                  6444.55
JPY       18/08/2010                145212.66             145212.66
              20/08/2010                2212545.55           2212545.55
AUD       18/08/2010                145212.66             145212.66
              20/08/2010                2212545.55           2212545.55
and so on...
Now I want to display these currency amounts with their own precision ie. 3 decimal places for BHD, 0 for JPy and 2 for AUD etc. I tried to use conditional formatting in display string function. In the display string I used select case like this-

select gridrowcolumn("currencycode")
case {IFX_CCY.ISO_CODE}  : cstr(currentfieldvalue,{IFX_CCY.DP});
default : cstr(currentfieldvalue);

But this isnt working.for the first record it always goes to case clause and then too not showing the correct decimal places and rest of the cases, it goes to default.
Please note am using Crystal reports in eclipse. 

Thanks a lot.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.