简体   繁体   English

排序交叉表报表 Crystal Reports

[英]Sorting a CrossTab Report Crystal Reports

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.不幸的是,“原始订单”在 Crystal Reports 交叉表中不起作用。 The original "order by" section of my sql query contained two column: first a nvarchar column then a int column.我的 sql 查询的原始“order by”部分包含两列:首先是 nvarchar 列,然后是 int 列。 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.在我的结果中,我只需要显示这两列的串联,因此结果通常与 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.但是当在Crystal Report交叉表中显示结果时,排序是不同的,因为交叉表的排序仅基于显示的列/行,而不是查询结果中的“原始排序依据”,因此结果与交叉表一起显示取而代之的是: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".我解决这个问题的方法是在我的“concat 字段”之前的行部分中添加这 2 个字段,因为它们是排序所必需的,并且只显示我的“concat 字段”。 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.希望它能帮助你们节省时间。

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.但是这个solution有一些限制,比如如果你想在Excel 中导出报告,那么它会在总计中添加额外的单元格 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示例:如果您有 3 行(A、B、C)要显示,并且您添加了一行并抑制它以解决您的排序问题,那么在Excel它的总计看起来像

 ABC a 1 3 b 2 2 --------------------------- Total: 3 5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM