COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: suhas_bhat on 26 Aug 2010 02:09:18 AM

Title: Rearranging members within a subset.
Post by: suhas_bhat on 26 Aug 2010 02:09:18 AM
Hi,
My members of a level are a,b,c,d,e,f.I have created a subset of first 3 members therefore i have a,b,c now. When i use this data item in my crosstab report it displays as a,b,c. I want to interchange the members so that they display as a,c,b.
What is the function to interchange members? I do not want to sort them on any value expression.
Please help.

Thanks.
Title: Re: Rearranging members within a subset.
Post by: CognosPaul on 26 Aug 2010 02:16:35 AM
The easiest way to do this would be to add a Sort Order to the attributes of the level. Then you could do something like:

order([MySet],[NS].[Dim].[Hier].[Level].[Sort] ASC)

If that's not possible then you'd have to use the set functions. ITEM, TAIL, HEAD, SET, and so on.

First you need to define the logic. Is it always going to be 3 items, A B C reordering to A C B?

set(item([MySet],0),item([MySet],2),item([MySet],1))

Can there be an unknown number of members? If so, does the last member need to go to the second place?

set(item([MySet],0),item(tail([MySet]),0),except([MySet],set(item([MySet],0),item(tail([MySet]),0))))

The more complex the logic, the more complex the statement. But as long as there is a consistent logic, then it's possible.
Title: Re: Rearranging members within a subset.
Post by: suhas_bhat on 26 Aug 2010 04:23:21 AM
Thanks Paul, this worked out perfectly.  :)