Reputation: 181
I am trying to sort the column group in crosstab but iReport is applying its own sorting by name ascending. I tried inserting "Order By Exp.", but it didn't work. (Field not found error!)
What is the correct way to add our own sorting by field/variable? Or I have presorted data, viewing it as it is will do.
Upvotes: 4
Views: 11468
Reputation: 21
Right click the crosstab in ReportInspector-->click on crosstab data a new window would open. Now click on Data is pre-sorted. this will do the work
Upvotes: 2
Reputation: 4755
this is a duplicate of Crosstab Sorting in JasperReports and the referenced "rather clean although tricky solution" based on hidden group(s) works quite well
Upvotes: 0
Reputation: 41
user1120946, for me what did the trick was to disable the total of the subgroup (e.g. Heading), and enable only the total of the overgroup (e.g. HeadingOrder). Then just put the measures in the HeadingOrderTotal column.
That is meant as a comment on the second answer.
Upvotes: 0
Reputation: 181
WORKAROUND:
Concatenate the field (to be used in the Column-Group) with the sort by field in the sql query itself. suppose field name is "title" and sort field name is "rank", then
select (mt.rank ||'-'|| mt.title) as title from my_tab mt
(Above query specific to postgresql)
Use this "title" field in corsstab column-group as usual.
Click on text field of "title" column group on crosstab.
Edit its "Text Field Expression" from properties panel as $V{title}.split("/")[1]
Upvotes: 2
Reputation: 2939
I had a similar problem. I wanted to display a "Heading" from the database, but I did not want it to sort alphabetically since the order of the headings were user determined.
I had a HeadingOrder field that I wanted to sort by. To use it in the sort expression it has to be in the cross tab.
I had heading in my column so made 2 column groups: 1) HeadingOrder 2) Heading.
I removed the text field that displayed the heading order number and collapsed that area so it did not display. This allowed the cross tab to display the Heading while using the HearingOrder field as the dominate sort.
Upvotes: 3