Cyrstal Reports data type in Case Statement

I've tried just about everything I can think of.  The formula below works awesome, however;  I would like the default to be 'Quoted' not 0.00  As we all know, CR cannot mix data types.  The hr_fromdate, gv_fromdate and cr_fromdate are integers (not date fields, not sure why they were named that way...)   Any thoughts on how I can force CR to display a string rather than a number as default?  Thanks so much!  

whileprintingrecords;
select {@cru}
    case "cru hr", "cru hr %" : {Command.HR_FromDate}
    case "cru gv" : {Command.GV_FromDate}
    case "cru cr" : {Command.CR_FromDate}
default : 0.00
LVL 1
Tina KSystems SpecialistAsked:
Who is Participating?
 
mlmccCommented:
I assume you are trying to display a value on the report and want it to be either a numeric result or a word.  So for display purposes use this formula
Name - DispFromDate
whileprintingrecords;
 select {@cru}
     case "cru hr", "cru hr %" : CStr({Command.HR_FromDate},0)
     case "cru gv" : CStr({Command.GV_FromDate},0)
     case "cru cr" : CStr({Command.CR_FromDate},0)
 default : "QUOTED"

Open in new window


For calculations use this one
Name- CalcFromDate
whileprintingrecords;
 select {@cru}
     case "cru hr", "cru hr %" : {Command.HR_FromDate}
     case "cru gv" : {Command.GV_FromDate}
     case "cru cr" :  {Command.CR_FromDate}
 default : 0

Open in new window


If you don't want 0 to be the default change it or use
whileprintingrecords;
 select {@cru}
     case "cru hr", "cru hr %" : {Command.HR_FromDate}
     case "cru gv" : {Command.GV_FromDate}
     case "cru cr" :  {Command.CR_FromDate}

Open in new window


mlmcc
0
 
mlmccCommented:
Try converting the numbers to strings

 whileprintingrecords;
 select {@cru}
     case "cru hr", "cru hr %" : CStr({Command.HR_FromDate},0)
     case "cru gv" : CStr({Command.GV_FromDate},0)
     case "cru cr" : CStr({Command.CR_FromDate})
 default : "QUOTED"

Open in new window


mlmcc
0
 
mlmccCommented:
If you need the numbers as numbers for another formula create the one I modified and use it in the display.

mlmcc
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
James0628Commented:
You may want to add ,0 to the last CStr function in mlmcc's formula, for consistency.  If you look at CStr in the CR Help, that should explain the arguments that you can give it to control the formatting of the values in the string.

 James
0
 
Tina KSystems SpecialistAuthor Commented:
@mimcc - the formula works great with the addition of the cstr function, but you're right, I do need the numbers as numbers for another formula.  I don't understand what you mean by "create the one I modified and use it in the display"  The other formula that uses the result of this formula is generating the error 'the string is non-numeric'.

Thanks!
0
 
Tina KSystems SpecialistAuthor Commented:
I should add that I did change formula #2 by adding tonumber - still generating the string is non-numeric error
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.