If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Sort Asc or Desc on Same Column in List object

Started by jriley, 07 Apr 2010 02:28:14 PM

Previous topic - Next topic

jriley

Working on a new report with the requirement to sort on a number column ascending or descending.  Haven't done this before on the same column alternately.  Been researching this and can't seem to find a way to sort on the same column within a list.  I've found ways to sort on different columns within the same list.  My workaround right now is two seperate lists on same page with alternate sorting, then rendering asc or desc list depending on parameter passed.  This works fine but seems there might be a better way to do this.  Any thoughts?  We're using 8.3.  If further detail would help, please let me know. 

Thanks in advance.
Joe

MFGF

Hi Joe,

One approach is to add a calculation to the query.  Depending on the parameter used to prompt for Ascending/Descending, get this calculation to contain either the original column value or the column value multiplied by -1 eg

if (?your parameter? = 'Asc') then ([your numeric column]) else ([your numeric column] * -1)

Sort the query on this calculation ascending, and add the calculation item as a property of the list (use the list's Properties property) - this is required since you are not displaying the calculation in the list.

Regards,

MF.
Meep!

jriley

mfgf, thank you very much for the suggestion.  i will give that a try and report back.

cheers,
joe

jriley

thanks mfgf!  i like this way much better. 

i ended up setting up a new data item m_AscDesc to conditionally set the number to a negative number if 'DESC' parameter passed in.  Otherwise use the positive number.

If (?sort-val? = 'DESC') then ([Number] * -1)
Else ([Number])

Then I plugged this into my sorting data item as follows: 

IF ( ?sort_val? = 'DATE' ) THEN
    ( [Start_Date] )
ELSE IF ( ?sort_val? = 'ASC' ) THEN
    ( [m_AscDesc ] )
ELSE IF ( ?sort_val? = 'DESC' ) THEN
    (  [m_AscDesc ] )
ELSE
    ( '' )

This is just what we needed here. 

Cheers,
Joe



MFGF

Excellent!  Thanks for posting up your solution - much appreciated! :)

MF.
Meep!