Jump to content
We've recently updated our Privacy Statement, available here ×

SEMI SOLVED: Crosstab sorting


vnug

Recommended Posts

 Hi:

I am trying to avoid the default sorting of Crosstab data by passing sorted data. But, it uses in-built data sorting and the resulting output is "atds-what-I-get.jpg". What I would like to get is in "atds-what-I-need.jpg". I am also enclosing the data set for this example. I have also tried the checking the option of "pre-sorted data". Then, I got lot of rows with "null" and some data. Even the data is incomplete. I would appreciate any pointers to fix this issue. 

Ideally I would like to use the "serial_no" column to order the data set and be able to get the crosstab output as in "atds-what-I-need.jpg". Thanks in advance.

 

best regards,

vnug



Post Edited by vnug at 04/06/2010 03:29
Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Eventhough "Data is Presorted" has always worked for me. One way of doing this is to create a new column and sort based on that column. For example you can use sort/decode like this

select case when tablename.fieldvalue = 'Sample1' then 1

                      when tablename.fieldvalue = 'Sample2' then 2

                      when tablename.fieldvalue = 'Average' then 3 end orderfield

from tablename

order by  orderfield

Link to comment
Share on other sites

Hi kchaudhry:

 

Thanks for your response. Unfortunately, I do not know the contents of row_name and param_name .... as they are dynamic. That was the reason I have a column "serial_no" (hoping to sort by this column to get the data in the order that I would need).  Unless I am missing something that is too obvious .... in your explanation, your query would not work in my case because I wouldn't know the dataset.

 

 

Link to comment
Share on other sites

Hi Kchaudhry:

I am trying to get your above example to work .... unfortunately, it is still not displaying data properly (assuming that I know the rownames and columnnames). Would it be possible for you to give me a jrxml file for the dummy data posted in the original post? Thank you.



Post Edited by vnug at 03/24/2010 10:30
Link to comment
Share on other sites

 Thanks, Kchaudhry for the sample file.

I am attaching  the output for my efforts. I have tried 3 different versions of iReport .... 2.0.0, 3.7.0, and 3.7.1.

Whenever I use pre-sorted data in the crosstab setup panel, I end up getting null values in the cells as shown. Here is my select statement -

select *, case when row_name='Sample1' then 0  when row_name='Sample2' then 1 when row_name='Average' then 2 end as order_ from data_values  order by order_

The select output gives me the output as in excel file (which is also enclosed). I am enclosing the output received for reference. I got the order needed for rows but the output contains unnecessary "null" values. Is there something I am not configuring??? Appreciate any pointers.

Link to comment
Share on other sites

  • 2 weeks later...

 Howdy all -

Thanks everyone for the helpful responses. 

The sorting can be done outside of what iReport forces. Unfortunately, it comes at a cost .... we need to know what the data contains. So, the steps if you know the data before:

1) Setup the SQL query with "case" statements to get the proper ordering

2) use pre-sorted data in the crosstab properties

3) Create hidden row and column (depending on whether you need private sorting rather than iReport sorting). These hidden fields will get you the sorting order you need. This step is "very much" needed, otherwise the output will contain lot of unnecessary "null"s.

Hope this helps.

Link to comment
Share on other sites

  • 7 months later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...