|
-
December 20th, 2011, 04:56 PM
#1
Case Statement
I am trying to create a case statement in Crystal Reports. I am pulling data that is related to the time of day. So, for instance, anything with a "0" hour is between 12:00 and 12:59 am, "1" is 1:00 to 1:59 am...
I need to case it that way, how do I do a case statement in Crystal syntax?
-
December 20th, 2011, 11:09 PM
#2
Re: Case Statement
Extracted from Crystal Reports help
Select expressions (Crystal syntax)
The Select expression is similar to an If expression. Sometimes however, you can write clearer and less repetitive formulas using the Select expression. For example, to evaluate the {Customer.Fax} field to determine if the area code is for Washington state (206, 360, 509) or British Columbia, Canada (604, 250):
Code:
//Select example 1
Select {Customer.Fax}[1 To 3]
Case "604", "250" :
"BC"
Case "206", "509", "360" :
"WA"
Default :
"";
The expression right after the Select keyword is called the Select condition. In the above example it is {Customer.Fax}[1 To 3]. The Select expression tries to find the first Case that matches the Select condition, and then executes the expression following the colon for that Case. The Default case is matched if none of the preceding cases match the Select condition. Notice that there is also a colon after the Default.
Code:
//Same effect as Select example 1
Local StringVar areaCode := {Customer.Fax}[1 To 3];
If areaCode In ["604", "250"] Then
"BC"
Else If areaCode In ["206", "509", "360"] Then
"WA"
Else
"";
Example
This formula groups the number of Oscar nominations a movie received into low, medium, high or extreme categories and in the process, shows some of the possibilities for the expression lists following the Case labels:
Code:
//Select example 2
Select {movie.NOM}
Case 1,2,3, Is < 1 :
(
//Can have expression lists by using
//parentheses
10 + 20;
"low"
)
Case 4 To 6, 7, 8, 9 :
"medium"
Case 10 :
"high"
Default :
"extreme"
The Default clause of the Select expression is optional. If the Default clause is missing and none of the cases are matched, then the Select expression returns the default value for its expression type. For example, if in the above example the Default clause were omitted and {movie.NOM} = 11, it would return the empty string "". The Select expression is an expression, and similar comments as in the More details on If expressions section apply to it as well.
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
December 26th, 2011, 06:49 PM
#3
Re: Case Statement
The syntax for crystal was pretty complicate. Sounded like visual syntax but had only stream output only. You didn`t have switch or case statements back then
Data values were the only ifs you had and I think user`s jxxxz answer is not true
You have no switches to sort data only filters for formatting (or flags).
-
December 26th, 2011, 07:49 PM
#4
Re: Case Statement
It's was not an answer and as i posted, it's an extract from Crystal Reports' help
Just provide what the OP asked for
... how do I do a case statement in Crystal syntax?
And I think that he can solve the problem using the Select or If expressions
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|