0
votes

Recently I had a problem with sorting a crosstab. I finally found a way to display the results as expected so I thought my solution may eventually help somebody else.

The "original order" doesn't work within Crystal Reports crosstabs unfortunately. The original "order by" section of my sql query contained two column: first a nvarchar column then a int column. In my results I only needed to display a concatenation of those two columns so the results normally looked like this with sql : A1, A2, A3, A10, A11.

But when it came to display the results in a Crystal Report crosstab, the sorting was different because crosstab's sorting is based on the columns/rows displayed only, not the "original order by" from the query results, so the results showed with the crosstab was instead: A1, A10, A11, A2, A3.

My way to solve this issue was to add those 2 fields within the rows section before my "concat field" because they were required for the sorting and to display only my "concat field". To hide fields within a crosstab, just go to this tab: "Customize Style Tab" (from the Cross-Tab Expert). Then select the field to hide within the Rows section and click "Suppress Subtotal" and then "Suppress Label". And it worked like a charm. Hopefully it will helps you guys saving time.

1

1 Answers

0
votes

But This solution have some limitations like if you want to export the report in Excel then it will add extra cells in grand total. otherwise it is a good to go.


Example: If you have 3 rows(A,B,C) to display and you added one row and you suppress it to solve your sorting issue then in Excel its grand total looks like

A            B            C
a            1            3    
b            2            2
---------------------------
Total:                    3            5