[英]How to group by one field and sort by another field with Crystal Report
I would like to group by one field and sort by another field with Crystal Report. 我想使用Crystal Report按一个字段分组并按另一个字段排序。
For example: Group A
with PO Number
(sort ASC). 例如:
Group A
和PO Number
(按ASC排序)。 For each PO Number, there is one Name with it and I would like to sort by Name_x
. 对于每个PO号,都有一个名称,我想按
Name_x
进行排序。
I have tried to add a field with Record sort Expert
or I created a new group with Name_x
and then sort by a new one but it does not work. 我试图用“
Record sort Expert
添加一个字段,或者用Name_x
创建了一个新组,然后按一个新的组进行排序,但它不起作用。
PO_1 Name_4
PO_2 Name_2
PO_3 Name_3
PO_4 Name_1
PO_5 Name_7
PO_6 Name_6
The result must be: 结果必须是:
Name_1 PO_4
Name_2 PO_1
Name_3 PO_1
Name_4 PO_1
Name_6 PO_6
Name_7 PO_5
I've found the solution as below and it works pretty well. 我发现以下解决方案,并且效果很好。 Please let me know if you have any idea.
如果您有任何想法请告诉我。
Solution: We will create summaries within each group which we can use for the sort function. 解决方案:我们将在每个组中创建汇总,以用于排序功能。
I would like to suggest an easy solution:- 我想提出一个简单的解决方案:
Your problem doesn't make any sense... If you have one PO Number who have only (unique) Name why then group by one attribute and sort by the other one? 您的问题没有任何意义...如果您有一个仅具有(唯一)名称的PO号,为什么要按一个属性分组并按另一个属性排序? You have relation 1:1 which means if you group by PO then you get result :
您具有1:1关系,这意味着如果按PO分组,则会得到结果:
PO_1 Name_4
P0_2 Name_2
If you group by Name then you get: 如果按名称分组,则会得到:
Name_1 PO_4
Name_2 PO_1
And that's it... You group by a attribute by which you want to sort by. 就是这样...您将要分类的属性分组。 If you have relation 1:N then this whole problem is solved by another way, but this is not important to this question.
如果您具有关系1:N,则可以用另一种方法解决整个问题,但这对这个问题并不重要。 Your solution with "suppressing" field work also but it's slower because you first group by some attribute, then suppress details, then calculating sum of it etc... this solution is a lot simplier
您使用“抑制”字段的解决方案也可以工作,但它的速度较慢,因为您首先按某个属性分组,然后抑制细节,然后计算其总和,等等。此解决方案非常简单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.