How to sort by month within a crosstab

0

For anyone looking to add sorting by month in their crosstab column header you might have noticed that you can only sort column headers by ascending or descending order only, they is no option to prevent sorting as far as I have see correct me if am wrong.

To be able to sort by month here is a little trick you can use.

Here is a simple sql statement that selects all agents total calls made each month in a call center

SELECT MONTH, total, agent FROM test.callcenter c;

take note month is an integer representations of months within the crosstab desgin navigate to the cell area with your month textField under textField expression add the following code

Code:
<textfieldexpression class="java.lang.String">
	<!--[CDATA[(
		$V{Month}.intValue() == 1 ? "Jan" : 
		$V{Month}.intValue() == 2 ? "Feb" :
		$V{Month}.intValue() == 3 ? "Mar" :
		$V{Month}.intValue() == 4 ? "Apr" :
		$V{Month}.intValue() == 5 ? "May" :
		$V{Month}.intValue() == 6 ? "Jun" :
		$V{Month}.intValue() == 7 ? "Jul" :
		$V{Month}.intValue() == 8 ? "Aug" :
		$V{Month}.intValue() == 9 ? "Sep" :
		$V{Month}.intValue() == 10 ? "Oct" : 
		$V{Month}.intValue() == 11 ? "Nov" : "Dec"
	)]]-->
</textfieldexpression>

see attached jrxml example [file name=crosstabExample.zip size=5236]

Post edited by: bones8800, at: 2008/03/14 03:23

Attachments: 
bones8800's picture
Joined: Mar 7 2008 - 11:55am
Last seen: 13 years 7 months ago

0 Answers:

No answers yet
Feedback
randomness