How can I group by two different fields in a Crystal Report?
如何在Crystal Report中按两个不同的字段进行分组?
Foe example :
敌人的例子:
val1|val2|val3|val6
val1|val12|val3|val7
val11|val2|val3|val8
val11|val12|val3|val9
I want the report to look like
我希望报告看起来像
val1 :
=======
val2
----
val3|val6
val12
-------
val3|val7
val11 :
=========
val2
-----
val3|val8
val12 :
------
val3|val9
2 个解决方案
#1
6
The generic data provided is rather vague, so I will provide my own to demonstrate (with field names on the first line)
提供的通用数据相当模糊,所以我将提供自己的演示(第一行有字段名称)
"EmployeeName","WeekNumber","DayOfWeek","HoursWorked" "John Doe",20,"Monday",8 "John Doe",20,"Tuesday",8 "John Doe",20,"Wednesday",8 "John Doe",21,"Thursday",8 "John Doe",21,"Friday",8 "Jane Doe",20,"Monday",8 "Jane Doe",20,"Tuesday",8 "Jane Doe",21,"Wednesday",8 "Jane Doe",21,"Thursday",8 "Jane Doe",21,"Friday",8
Assuming that I read the question correctly, you would want the report to look like this:
假设我正确地阅读了问题,您希望报告看起来像这样:
John Doe Week: 20 Monday 8 hours Tuesday 8 hours Wednesday 8 hours Week: 21 Thursday 8 hours Friday 8 hours Jane Doe Week: 20 Monday 8 hours Tuesday 8 hours Week: 21 Wednesday 8 hours Thursday 8 hours Friday 8 hours
If this is the case, you would group by the "EmployeeName" field first, and then simply add another group for "WeekNumber" via the Insert menu using the Group option. This is pretty straightforward, and you can do summaries on the fields at various levels. The only thing that would get "hairy" with multiple tier of grouping would be if you were calculating fields within the group and wanted to return those calculations to a higher level of grouping for summation, which would require declaring global variables within the report.
如果是这种情况,您将首先按“EmployeeName”字段进行分组,然后使用“组”选项通过“插入”菜单为“WeekNumber”添加另一个组。这非常简单,您可以在各个级别的字段上进行摘要。如果您计算组内的字段并希望将这些计算返回到更高级别的分组以进行求和,那么唯一可能通过多层分组获得“毛茸茸”的事情就是需要在报告中声明全局变量。
For what it's worth, I've been using Crystal Reports heavily for the past 7 years.
值得一提的是,过去7年来,我一直在大量使用Crystal Reports。
#2
0
Not sure on best practices, but what I've used to do similar in the past was a sub report with it's own grouping, within the first group.
对最佳实践不确定,但过去我曾经做过类似的事情是在第一组中有一个子报告,它有自己的分组。
So it would look something like this:
所以它看起来像这样:
MainReportHeader SubReport(?) SubreportHeader Values SubReportFooter MainReportFooter
MainReportHeader SubReport(?)SubreportHeader Values SubReportFooter MainReportFooter
Again, not a crystal expert, just an idea and something I've used before. There is probably a much easier way.
再一次,不是水晶专家,只是一个想法和我以前用过的东西。可能有一种更简单的方法。
#1
6
The generic data provided is rather vague, so I will provide my own to demonstrate (with field names on the first line)
提供的通用数据相当模糊,所以我将提供自己的演示(第一行有字段名称)
"EmployeeName","WeekNumber","DayOfWeek","HoursWorked" "John Doe",20,"Monday",8 "John Doe",20,"Tuesday",8 "John Doe",20,"Wednesday",8 "John Doe",21,"Thursday",8 "John Doe",21,"Friday",8 "Jane Doe",20,"Monday",8 "Jane Doe",20,"Tuesday",8 "Jane Doe",21,"Wednesday",8 "Jane Doe",21,"Thursday",8 "Jane Doe",21,"Friday",8
Assuming that I read the question correctly, you would want the report to look like this:
假设我正确地阅读了问题,您希望报告看起来像这样:
John Doe Week: 20 Monday 8 hours Tuesday 8 hours Wednesday 8 hours Week: 21 Thursday 8 hours Friday 8 hours Jane Doe Week: 20 Monday 8 hours Tuesday 8 hours Week: 21 Wednesday 8 hours Thursday 8 hours Friday 8 hours
If this is the case, you would group by the "EmployeeName" field first, and then simply add another group for "WeekNumber" via the Insert menu using the Group option. This is pretty straightforward, and you can do summaries on the fields at various levels. The only thing that would get "hairy" with multiple tier of grouping would be if you were calculating fields within the group and wanted to return those calculations to a higher level of grouping for summation, which would require declaring global variables within the report.
如果是这种情况,您将首先按“EmployeeName”字段进行分组,然后使用“组”选项通过“插入”菜单为“WeekNumber”添加另一个组。这非常简单,您可以在各个级别的字段上进行摘要。如果您计算组内的字段并希望将这些计算返回到更高级别的分组以进行求和,那么唯一可能通过多层分组获得“毛茸茸”的事情就是需要在报告中声明全局变量。
For what it's worth, I've been using Crystal Reports heavily for the past 7 years.
值得一提的是,过去7年来,我一直在大量使用Crystal Reports。
#2
0
Not sure on best practices, but what I've used to do similar in the past was a sub report with it's own grouping, within the first group.
对最佳实践不确定,但过去我曾经做过类似的事情是在第一组中有一个子报告,它有自己的分组。
So it would look something like this:
所以它看起来像这样:
MainReportHeader SubReport(?) SubreportHeader Values SubReportFooter MainReportFooter
MainReportHeader SubReport(?)SubreportHeader Values SubReportFooter MainReportFooter
Again, not a crystal expert, just an idea and something I've used before. There is probably a much easier way.
再一次,不是水晶专家,只是一个想法和我以前用过的东西。可能有一种更简单的方法。