If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to sort a data item dynamically

Started by inu, 26 Feb 2014 09:41:53 PM

Previous topic - Next topic

inu

Hi
There is scenario i got, where
1. two prompts are there in report page each with ascending / descending options
2. two colums say country, city

but i m not able to solve the problem. sending the screenshot, please go through it , and help me out.

Regards
Inam

Francis aka khayman


BigChris

I think I can see what you're getting at, but I'm not sure how to solve it for you. It looks like you want to conditionally sort asc / desc on Country, followed by asc / desc on City. I can do that with numeric fields, but I'm not sure how to achieve it for alphanumeric fields.

navissar

Chris, you're on the right track, what you're missing is the fact that a rank function will in fact rank string alphabetically.
So, here's a step by step:
1. You want to create a data item that would be your "sort item". Call it "Country_Sort_Item". The expression is
rank([country] #prompt('countryDir','token','asc')#)
This expression will take the value from the sort prompt (Default to asc).
2. Highlight the list, in Properties Pane under Data find "Grouping and sorting". Drag your Coutry_Sort_Item to the sort list folder under the "Country" group.
You're basically done. The prompt will pass on "Asc" or "Desc" to the rank function which will do the sorting.
Repeat for city.

adik

i have two sollutions for you:
1.
you either create 4 lists sorted by each combination: coutry ascending + city ascending / country ascending + city descending ...
you then create variables and based on selection you render one of the lists

this is not a very clean and mantanable sollution but will get the job done

2.
create 4 query items with the following formulas:
[Country ASC]
rank([Country] ASC at [Country])

[Country sort]
case
when ?p_country_sort? = 'ascending' then [Country ASC]
when ?p_country_sort? = 'descending' then (-1 * [Country ASC])
end


[City ASC]
rank([City] ASC for [Country])

[City sort]
case
when ?p_city_sort? = 'ascending' then [City ASC]
when ?p_city_sort? = 'descending' then (-1 * [City ASC])
end


in your list place both [Country sort] and [City sort], sort the list by the 2 query items ascending and set the box property for the 2 columns to none
?p_country_sort? and ?p_city_sort? are you parameters for the sorting selection, make them autosubmit

mitwa

1st method:

just create two list in one page..make one list as ascending usins sort option and another as descending then write one string variable..

case when ParamDisplayValue('asc/dsc')='asc' then 'show' else 'hide' end

like this show 1st list wen asc and 2nd list wen dsc..

thts it..better and simple way

2nd method

using static choice assign 1 as asc & 2 as dsc

then create dataitem1 in d query as  Case when  ?asc/dsc?= 1 then [city]  end
                    dataitem2 in d query as  Case when  ?asc/dsc?= 2 then [city]  end

thts it...

3rd method

do as tht as above bt drop tht dataitem1 and 2 inside d city in list page..


these all will help u ;)