# 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?

###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by