COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: wzewald on 01 Sep 2016 12:36:42 PM

Title: Trouble sorting a calculated column
Post by: wzewald on 01 Sep 2016 12:36:42 PM
I am trying to sort a column that is the result of a calculation. I have a column with ticketnumbers and a column with usernames. The numbers are unique but the users are not so I want to have a count of the number of tickets per user. If I have the column with the users first and then the ticketnumbers, I can group on the users. The I add a count to the ticketnumbers column and then it the amount of times they appear.

-------- --------
user1   | 3
-------- --------
user2   | 5

My problem is that I am unable to sort the second column. I want the highest number up top but the sorting has no effect at all. I am baffled. I can write a query in SQL that should work in a normal SQL app but here it just gives me lot's of syntax errors. I am stuck....

By the way: I am new to the program. Love the possibilities!
Title: Re: Trouble sorting a calculated column
Post by: Francis aka khayman on 02 Sep 2016 02:32:49 AM
shouldn't you be sorting the first column based on the second column?
Title: Re: Trouble sorting a calculated column
Post by: hespora on 02 Sep 2016 02:46:27 AM
I think your problem is the grouping. If you just want the count of unique ticket numbers, you shouldn't have to group:

From an empty report,

1. drag in your user
2. drag in your ticket number
3. modify the ticket number to count(distinct [ticketno] for [user])
4. sort ticket number descending

/edit: or, if you absolutely have to have the grouping, do what khayman said: Go into Grouping and Sorting for your list and move ticket number from nested in detail sort list to nested in groups>[user]>sort list
Title: Re: Trouble sorting a calculated column
Post by: wzewald on 05 Sep 2016 08:28:27 AM
Quote from: hespora on 02 Sep 2016 02:46:27 AM
I think your problem is the grouping. If you just want the count of unique ticket numbers, you shouldn't have to group:

From an empty report,

1. drag in your user
2. drag in your ticket number
3. modify the ticket number to count(distinct [ticketno] for [user])
4. sort ticket number descending

/edit: or, if you absolutely have to have the grouping, do what khayman said: Go into Grouping and Sorting for your list and move ticket number from nested in detail sort list to nested in groups>[user]>sort list

This absolutely helped me! The expression worked like a charm! Sorting works too now!!
Title: Re: Trouble sorting a calculated column
Post by: hespora on 05 Sep 2016 10:32:18 AM
Wonderful! :)