COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cygnex on 17 Sep 2008 05:23:56 AM

Title: Dynamically Change the Order of Columns in Report
Post by: cygnex on 17 Sep 2008 05:23:56 AM
I have seen many postings regarding the hiding of columns but in my research I have not found a method to change the order of display.  I would like a user to not only be able to choose which columns are displayed via prompts but provide an option to change the order of columns as well.

Has anyone done this?
Title: Re: Dynamically Change the Order of Columns in Report
Post by: blom0344 on 17 Sep 2008 08:13:12 AM
The report definition is stored as an XML type. XML is typically read from top to bottom, which means that the order in which columns are presented are derived from the order in which they appear in the XML structure. From that perspective it seems pretty hard to make a dynamic order work.
However it should be possible to design report pages with alternative order of columns and then just show the one that the user prefers.
But, perhaps someone has a work-around?
Title: Re: Dynamically Change the Order of Columns in Report
Post by: cygnex on 19 Sep 2008 11:16:02 AM
Yes, thanks for the reply.  I think having separate reports with different orders is the only way to go.  People are complaining that my reports are not flexible enough, even though every report I create is also available via Excel.
Title: Re: Dynamically Change the Order of Columns in Report
Post by: the_xxx on 19 Sep 2008 03:03:05 PM
Hi....

I have a quick solution. But I dont know how it can help you.

1. Create value prompts based on your requirement ( ex: 5 value prompts for if you have 5 columns in the report)

2. Add static choices to the value prompts.
    Ex: value_prompt_1 will have 5 static choices with all the column names.
          value_prompt_2 will have 5 static choices with all the column names....etc

    so, there will be 5 values prompts with all the column names in them.

3. Now, in the query create five data items with same custom calc to display the required column.

   ex:   if(?value_prompt_1? = 'One')
then([Query1].[one])
else
if(value_prompt_1 = 'Two')
then([Query1].[Two])
else
if(?value_prompt_3? = 'Three')
then([Query1].[Three])
else
.
.
.
.
.
.
if(?value_prompt_5? = 'Five')
then([Query1].[Five])
else


so. you will have 5*5 = 25 drevied feilds.

drag and drop them in list.

now...when you run the report ...give the column name in the prompt...it will show the same order in the report.


----thats it!!!
:)


     

Title: Re: Dynamically Change the Order of Columns in Report
Post by: cygnex on 19 Sep 2008 08:34:08 PM
What can I say.  This is IT!!!!!!!!!!!!!!!!!!!!!!!!!!!

You saved me, thanks forever.
Title: Re: Dynamically Change the Order of Columns in Report
Post by: the_xxx on 20 Sep 2008 11:59:22 PM
Enjoy !!  :)
Title: Re: Dynamically Change the Order of Columns in Report
Post by: rpezzulo on 23 Dec 2008 11:36:33 AM
The proposed solution may be helpful with a limited data set such as the 5 column report mentioned. This is not truly dynamic as you need to create a scenario for each possible case. What if the report had 100 possible columns? In that case, this approach would be extremely tedious. Has anyone implemented a similar solution with a truly dynamic sorting of columns? My data is setup so that I have column names and field orders in a table. Trying to determine how to implement dynamic selection and sorting of columns in a crosstab.