COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: jd on 08 Feb 2011 10:55:46 AM

Title: Radio buttons for sort the date column
Post by: jd on 08 Feb 2011 10:55:46 AM
Hi,  I have a list report with date column.

I need to add 2 radio bittons top of the list for sort the date column.

radio button one for ascending and one for descending.

Can I get any help how to achive this?

Thanks
Title: Re: Radio buttons for sort the date column
Post by: PRIT AMRIT on 08 Feb 2011 08:14:40 PM
Well, if you are not keen to use JAVA script then I would suggest to have to two date prompts i.e. One with Ascending sort and another one is Descending sort.

Then Hide/show these two Date Prompts based on your Radio Button prompt input parameter.

Does it make any sense?

Thanks
P
Title: Re: Radio buttons for sort the date column
Post by: JGirl on 08 Feb 2011 10:28:48 PM
Assuming:
1.  You have a numeric date column you can use in YYYYMMDD format (eg. 20110131) called [NumericDate].
2.  You have 1 value prompt, radio buttons with 2 static choices (use and display values 'Asc' and 'Dsc' ) with a parameter called ?DateSortOrder?

In your main query, create a column called [DateSortOrder], derived as
IF (?DateSortOrder? = 'Asc')
THEN ([NumericDate])
ELSE ([NumericDate]*-1)

Then use the [DateSortOrder] column to sort your list in ascending order (as the prompt-driven multiplication by -1 will reverse the order when necessary).

Put your radio button prompt on the report page and make it auto-submit.
Title: Re: Radio buttons for sort the date column
Post by: melee on 08 Feb 2011 10:59:42 PM
Quote from: JGirl on 08 Feb 2011 10:28:48 PM
Assuming:
1.  You have a numeric date column you can use in YYYYMMDD format (eg. 20110131) called [NumericDate].
2.  You have 1 value prompt, radio buttons with 2 static choices (use and display values 'Asc' and 'Dsc' ) with a parameter called ?DateSortOrder?

In your main query, create a column called [DateSortOrder], derived as
IF (?DateSortOrder? = 'Asc')
THEN ([NumericDate])
ELSE ([NumericDate]*-1)

Then use the [DateSortOrder] column to sort your list in ascending order (as the prompt-driven multiplication by -1 will reverse the order when necessary).

Put your radio button prompt on the report page and make it auto-submit.

Wow, nice form JGirl. That makes a lot of sense.
Title: Re: Radio buttons for sort the date column
Post by: jd on 09 Feb 2011 04:20:15 PM
Hi JGirl,

I have only start date column in my report. So can I use this column for [NumericDate] and [DateSortOrder]

or [DateSortOrder] should be different than [NumericDate]?

Thanks

Title: Re: Radio buttons for sort the date column
Post by: jd on 10 Feb 2011 02:00:20 PM
Hi JGirl,

I have followed your below steps but none of the recods come.
Title: Re: Radio buttons for sort the date column
Post by: Arsenal on 10 Feb 2011 03:04:25 PM
Quote from: d.laxmi on 09 Feb 2011 04:20:15 PM
Hi JGirl,

I have only start date column in my report. So can I use this column for [NumericDate] and [DateSortOrder]

or [DateSortOrder] should be different than [NumericDate]?

Thanks

She's asking you to create a value prompt whose parameter she's suggesting be named as DateSortOrder. You don't need a "start date" or "end date" at all .
As per her suggestion, you would also create a data item in your main query called DateSortOrder, or you can name it something else.
And then finally, you would use this newly created data item query to be used to sort the list (grouping and sorting option in the properties pane of the list) ascending (by default when you add this data item into the sort list, it will be set to ascending)

Title: Re: Radio buttons for sort the date column
Post by: sram007 on 23 Feb 2011 04:10:09 AM
Hi JGirl,
I have a list report which is having 2 colums like,
Product Line,Product Type i want to sort these colums dynamically so i have added a valueprompt static choice as Asc & Dsc .& in report design i have added a new calculated  item named Sort as given below,
IF (?Sort? = 'Asc')
THEN ([Product Line])
ELSE ([Product Type]*-1)
But Its not working Please Guide me..

Regards,
Ram
Title: Re: Radio buttons for sort the date column
Post by: jive on 23 Feb 2011 08:07:07 AM
Hi SRAM007 ,

Just one thing, when you do number*-1 it's change the order because is a number, with text a doubt this will work.

regards Jacques
Title: Re: Radio buttons for sort the date column
Post by: sram007 on 24 Feb 2011 03:36:03 AM
You are right Jive.
Can any one please help me in this case

Cheers,
Ram
Title: Re: Radio buttons for sort the date column
Post by: jive on 24 Feb 2011 09:54:39 AM
HI SRAM,

In the project I work now, we avoid that problem by setting a column in the dimension. that column will hold a number indicating the text position in the order the client want it. That way we can have a text order like 'z','c','u','a' by default or the client can have have it in asc or desc based on the text itself. If they want the same order base on the numeric value but in reverse, I hope I'm clear that sound strange, we used the solution Jgirl propose earlier, mulitply the sort_ket*-1.

Jacques