COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: nishithshri on 13 Mar 2017 01:21:28 PM

Title: Sort Parameter Values on Report Page
Post by: nishithshri on 13 Mar 2017 01:21:28 PM
I have a multi select prompt in the report page which is sorted descending. I am displaying parameter values that are selected in the prompt at the title of my report (paramdisplayvalue). I want paramdisplayvalues in the title of the report to be sorted as ascending. I have tried a few options but it did not work so far !!

Any help would be appreciated !!
Title: Re: Sort Parameter Values on Report Page
Post by: AnalyticsWithJay on 14 Mar 2017 07:17:48 AM
Here you go:


#sq(csv(sort(split(';', promptmany('ParameterName', 'string'))), ',', ''))#


From the inner most function:
1. Get the prompt values.
2. We need to construct an array before we can sort. The values are separated by a semi-colon.
3. Sort.
4. Return the sorted values, comma separated.
5. Encapsulate in single quotes to display a final string.

Macro-functions can be very powerful if you get comfortable with using them.
Title: Re: Sort Parameter Values on Report Page
Post by: nishithshri on 14 Mar 2017 11:51:16 AM
Hello CognoidJay, this works great. I created a data item and used it in place of paramdisplayvalues and it worked like a charm. Thank you very much. However is it possible to get the string without single quotes. Currently i am getting it as: 'a','b','c' and i want it as: a, b, c.
Title: Re: Sort Parameter Values on Report Page
Post by: nishithshri on 14 Mar 2017 12:03:10 PM
I spoke too soon. I tried replace function on the macro and it gave what i wanted. Thanks again for your help, CognoidJay. I am not into macros much but should learn more about it.
Title: Re: Sort Parameter Values on Report Page
Post by: AnalyticsWithJay on 14 Mar 2017 02:57:29 PM
Quote from: nishithshri on 14 Mar 2017 12:03:10 PM
I spoke too soon. I tried replace function on the macro and it gave what i wanted. Thanks again for your help, CognoidJay. I am not into macros much but should learn more about it.

Great to hear  :). Macros have been underutilized because they were only visible in FM for the longest time.

Cheers,
Jay