• Status: Solved
• Priority: Low
• Security: Public
• Views: 51

# Crystal Report Sort Formula

I have a Crystal Report formula for a parameter I enter.  The first two work great, number three is not sorting how I want it.

It is sorting it like below:

0
1
2
3
4

I would like it sorted like:

20
19
18
17
16

The formula is below:

if {?SortColumns} = '1' then {Command.findname} else
if {?SortColumns} = '2' then {Command.lendercode} else
if {?SortColumns} = '3' then totext({Command.age},"00",0)

I want option number three to sort descending.  What in the world am I doing wrong?

0
ldhon
1 Solution

Commented:
You only have 1 sort field.  There is no way to change from ascending to descending

Try this idea.  Use 2 formulas.  Set one to be ascending and the other to be descending

AscendingSort
``````if {?SortColumns} = '1' then
{Command.findname}
else  if {?SortColumns} = '2' then
{Command.lendercode}
else  if {?SortColumns} = '3' then
" "
``````

Descending Sort
``````if {?SortColumns} = '1' then
0
else  if {?SortColumns} = '2' then
0
else  if {?SortColumns} = '3' then
{Command.age}
``````

Use them as the sorting formulas and set the order appropriately

mlmcc
0

Author Commented:
Thank you very much mimcc.  Your solution is greatly appreciated.
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.