Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use two different data types in a formula result 1

Status
Not open for further replies.

CrystalSS

Technical User
Nov 15, 2002
8
0
0
US
Hello all.

I want to create a formula based on a parameter to let users choose whether or not to group the report by a date field or a text field.

The basics are easy and I already have the formula created that allows for the group to work for all the text fields I want, however, I can't have the formula results be two different data types.

For example I have:
If {field 1}= "X" then "Text 1"
else if {field 1}= "Y" then "Text 2"
else {Date field}

I get an error in my formula because the final else statement is expecting another text field. I can change the date to text but then it doesn't sort properly.

Is there any way to make Crystal allow multiple data types to be displayed?

If not, is there a way to skip a group all together?
For example
Group 1 sorts by the text fields if field 1 is X or Y
Group 2 sorts by Date

Then I could have group 1 skipped entirely if I need to show a date?

I know that I can conditionally suppress the group, but it still sorts by the text field.

Thanks.
 
You could use the original formula if the Date was formatted is such a way that it would be sorted correctly, right?

If you convert the Date to text like this, it should sort correctly:
ToText({Table.Date},"yyyyMMdd")

-dave
 
Dave described this perfectly, add to this that you use his formula for grouping only, place both fields in the group for display purposes and conditionally suppress.

BTW< your idea of suppressing groups can work (you would conditionally change the outer group tp be all one value if a date is selected), but Dave's solution is simpler.

-k
 
Thanks Vidru and Synapsevampire.
I'll go ahead and use this. I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top