Sorting Cross-Tab columns in Crystal Reports

crystal-reportsreportsorting

I've been working in a Crystal Reports project where I have to show a sum of values gruped in columns by months.

I've to proccess a range of a year from the specified date in parameters. So I've used Cross-Tabs, grouping by columns of @MONTH_DISPLAY, defined by: month({ASIENTOI.DATE}).
The important fact is that I've to sort columns by the earliest month to a year from it. Which means:
If the user set the date by 10-07-12, I've to show colums sorted like this:
July (2012) – … – June (2013).

The problem is that Crystal Reports set that range like this:
Jan (2013) – … – June (2013) – July (2012) – … – December (2012).

And I just can't find the way to get that sorting modified.

Best Answer

The only way to sort cross-tab columns via designer is choosing between descending or ascending order, this means crystal report will order your fields by alphabetical order.

A possible workaround is, for example, putting numbers with an underscore before the string you want to order in your datasource (like 01_July (2012), 02_August (2012)...13_June (2013)) and use the order ascending, then to hide the numbers, go in the "cross-tab expert" section and on the cross-tab tab choose "group option" under the columns (sorry I only have it in Italian) Group option

and on the option tab choose the options below

Option tab

click on the formula button and use the function

Right(yourField,Length(yourField)-3)

to exclude the prefix so you will not have "01_July (2012)" on the cross-tab colum but "July (2012)". This should do the trick

Related Topic