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

Dynamic Sort 2

Status
Not open for further replies.

ashishh

Programmer
Jul 19, 2002
43
0
0
US
Hi,

First of all, thanks for your time.

I have a situation where in I need to sort the columns based on the filter selection. If choice "A" is made then I want the detail records sorted by Column #3, else by Column #4.

I have tried looking for anyway to specify dynamic sort order without luck. Does someone have any experience with this?

Thanks,
Ashish
 
Ashish,

Create a calculated column in your report query (it doesn't have to appear in the report output). Define this column as:

If (UPPER(?SortBy?) = 'A') then (rptcol1) else (rptcol2) ...

where ?SortBy? is your prompt and rptcol1&2 are your two report columns you want to dynamically sort by.

Then just sort the report by the calculated column.

The same logic applies to dynamic grouping. If you are on Oracle you can use the Decode function for more efficiency.

Hope this helps.

Regards,

Dave Griffin


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Dave,

Excellent suggestion. Wonderful workworund! I sincerely appreciate your contributions to this forum.

Ashish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top