Print Page | Close Window

Case statement as a formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6513
Printed Date: 27 Apr 2024 at 9:09pm


Topic: Case statement as a formula
Posted By: brent21090
Subject: Case statement as a formula
Date 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



Replies:
Posted By: rahulwalawalkar
Date 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


Posted By: brent21090
Date Posted: 29 May 2009 at 6:38am
That worked. 
Now what does word "Default:" mean at the end of the statement?
Thanks Raul
 
Lucy


Posted By: rahulwalawalkar
Date 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


Posted By: brent21090
Date Posted: 29 May 2009 at 6:48am
Thank you


Posted By: kathuriap
Date 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.



Print Page | Close Window