COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Cognos10x on 20 Jul 2015 10:59:50 AM

Title: Dynamic Sorting based on Dimensional source
Post by: Cognos10x on 20 Jul 2015 10:59:50 AM
Hi Experts,

I have a requirement where I have to do nested sorting on my list report based on the 3 columns the users selects. This could be ascending or Descending. I am using DMR model and my version is 10.2.2

How do I achieve this?

 

Thanks in advance.
Title: Re: Dynamic Sorting based on Dimensional source
Post by: gpollock on 20 Jul 2015 03:49:55 PM
How about trying this:

Create a new data item in your query.  Call it Sort1.  For the expression, use a case or some other logic to give it a value based on your parameter.  For example, if param1 is "Report Date", then column Sort1 will be the date column.  If param1 is "Item", then Sort1 will be the item.  Repeat so you also have a Sort2 and a Sort3.  Then just tell your list to sort by Sort1, then Sort2, then Sort3.

Now you have the trouble of making it go ascending or descending.  It's simple if you're working with numbers, but letters may be more complicated.

Title: Re: Dynamic Sorting based on Dimensional source
Post by: Cognos10x on 20 Jul 2015 11:28:09 PM
I am familiar with the logic part. My problem is how to make it dynamically sort it asc or desc. For instance User wants to have combination of asc or desc of col1, col2, and Col3. How can we put this logic in place?
Title: Re: Dynamic Sorting based on Dimensional source
Post by: gpollock on 21 Jul 2015 08:55:42 AM
I don't think Cognos has any event rules, and I personally don't like using javascript in reports, so personally, I would do dynamic sorting via the case statements.  In your case, you would have six "special" columns, which are populated based on your parameters.  For more information, here's an IBM guide on how to do it. http://www.ibm.com/developerworks/data/library/cognos/reporting/scripting_techniques/page515.html

If you want to try something with javascript or use another method, there are a few guides you can find by googling "cognos report dynamic sorting"