COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: philelmousse on 02 Feb 2011 04:26:31 AM

Title: Sort data in a specific way
Post by: philelmousse on 02 Feb 2011 04:26:31 AM
Hello, how to sort a column not in alphabetical way ?
Title: Re: Sort data in a specific way
Post by: MFGF on 02 Feb 2011 07:17:17 AM
How do you want it to be sorted?
Title: Re: Sort data in a specific way
Post by: jive on 02 Feb 2011 09:41:29 AM
Hi Phil,
For sorting data you will need a column, if you don't have it in your model you need to build it a report time. Like

data item: sort_col2
case [some_data].[data_itself]
   when 'A' then 4
   when 'B' then 3
   when 'C' then 1
  when  'D' then 2
  else 5
end
That way when you sort your data by the column sort_col2 it will be on the order you need. put the data item at the end of your list or crosstab and chose the properties "Box type" and select non, the column will be hidden.
One other thing is when you build your model, it's a good thing to always leave a column for sorting in a special way, by that a mean other sort then alphabetical or numeric.
Title: Re: Sort data in a specific way
Post by: philelmousse on 02 Feb 2011 09:58:24 AM
i add a "sorting column" with number (1,2,3,4) in my list and make the sort with that column. I delete that column to try and it still sorted. Thats normal ?
Title: Re: Sort data in a specific way
Post by: jive on 02 Feb 2011 12:22:08 PM
Did you delete or hide the column, if you delete i'm not sure how many it will stay in that order, but if you hide the column it will stay.

Regards Jacques
Title: Re: Sort data in a specific way
Post by: RobsWalker68 on 02 Feb 2011 05:17:19 PM
Hi,

In your report click on the Query Explorer tab and add an item to your query to create your sort order e.g. using the Go Sales (Query) example:

Case
When [Product line] = 'Camping Equipment' then '5'
When [Product line] = 'Golf Equipment' then '1'
When [Product line] = 'Mountaineering Equipment' then '2'
When [Product line] = 'Outdoor Protection' then '3'
When [Product line] = 'Personal Accessories' then '4'
end

Click on your page and then using the ancestor button choose your object e.g. List.  In its properties click on the ellipsis next to Grouping and Sorting and add the sort data item created above to the detail sort list.  This way you do not need to add it to your actual layout.

Kind Regards

Rob
Title: Re: Sort data in a specific way
Post by: philelmousse on 03 Feb 2011 03:01:28 AM
thanks a lot Rob, really good to know  :)