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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Crystal Reports sorting by either a date or a number column 1

Status
Not open for further replies.

jchewsmith

Technical User
Nov 20, 2006
161
US
I have a report that I want to put in a paramater to sort by either the due date column of the quoted amount column.

I have tried to group by the sort option but it doesn't allow two different field types.

Is there a way to have a parameter to let the user choose which column they want to sort by when they are two different field types?

if {?Sort Option} = 'Quoted Amount' then {SSRpt_NOW.Quoted Amount}
else {SSRpt_NOW.DUE DATE} I GET AN ERROR MESSAGE EXPECTING A NUMBER AFTER THE ELSE.

 
Part of the issue is that the THEN of the IF and the ELSE of the IF have to be the same data type. If you can convert the one (or both) of the fields to a common data type, it might work for you.
 


In VB you can convert a date to a LONG integer or DOUBLE precision using a function.

Do you have such a conversion function?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I tried converting the date to an integer but couldn't figure out how to do. Any ideas?
 
You can use ToText to convert both to 'string'. For dates, something like
Code:
ToText({your.date}, "yyyy/MM/dd")

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
You can use the totext function as suggested, or you could add two formulas to the sort records area:

if {?sort} = "Amount" then {table.amount}

if {?sort} = "Date" then {table.date}

Since the default will be either 0 or date(0,0,0), the sort that does not apply will have no impact.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top