COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cognosun on 20 Jun 2013 05:53:49 AM

Title: sorting - positive and negative values
Post by: cognosun on 20 Jun 2013 05:53:49 AM
Hi Gurus,

I've got these values under a column : 10, 6,-2,1,-5,9,0

I want report output in this way, in descending :

10
9
6
-5
-2
1
0

Can anyone suggest a way....

Many thanks in advance,

Joys



Title: Re: sorting - positive and negative values
Post by: blom0344 on 20 Jun 2013 06:28:56 AM
2nd dataitem with a case that sets an 'index' for the right order in which you want it displayed:

CASE WHEN
[ITEM] = 10 THEN  '1'
WHEN [ITEM] = 9 THEN '2'
................
WHEN [ITEM] = -5 THEN '4'
................
WHEN [ITEM] = 0 THEN '7'
END

Are you up for an exam?
Title: Re: sorting - positive and negative values
Post by: cognosun on 20 Jun 2013 06:30:17 AM
hmmm....these are just sample rows...i need to handle 2k rows :-)
Title: Re: sorting - positive and negative values
Post by: BigChris on 20 Jun 2013 06:33:50 AM
Have you tried creating a calculated field abs(value) - i.e. taking the absolute value of your field - and sorting on that instead? I think that should do the trick..let me know.
Title: Re: sorting - positive and negative values
Post by: blom0344 on 20 Jun 2013 06:59:06 AM
Quote from: BigChris on 20 Jun 2013 06:33:50 AM
Have you tried creating a calculated field abs(value) - i.e. taking the absolute value of your field - and sorting on that instead? I think that should do the trick..let me know.

Yes,of course Chris..  I didn't see the pattern here   ;D
Title: Re: sorting - positive and negative values
Post by: cognosun on 20 Jun 2013 08:47:02 AM
OK.

I'll try to sort descending on the absolute values ( already did this but didn't work...will re-try).

And this is first hurdle...second hurdle is to identify that negative value and making it red ( using conditional variables we can do this) but how to identify those negative values which are already turned positive :-)

Not exam exactly :-)

Title: Re: sorting - positive and negative values
Post by: BigChris on 20 Jun 2013 08:54:24 AM
Don't change the actual values to be positive - create a second column with the absolute value in. That way you retain the original negative / positive value which will allow you to use conditional formatting ... and will also mean that any totals or aggregates on the column are still correct. Then do your sorting on this second column, leaving your original column alone