简体   繁体   English

Crystal Reports组排序

[英]Crystal Reports group sorting

I have flight data records for each user. 我有每个用户的航班数据记录。 The table below shows an example for one user id. 下表显示了一个用户ID的示例。 I need to group by user_id (show only one row for each user_id) that has the latest flight_date. 我需要按具有最新flight_date的user_id分组(每个user_id仅显示一行)。

When I added grouping by user_id, the result report displays the right flight date, but the rest of the fields come from the last row for each user (highlighted fields).How do I make it show the entire row with the latest date (4th row in my example)? 当我添加按user_id分组时,结果报告会显示正确的排期日期,但其余字段来自每个用户的最后一行(突出显示的字段)。如何使整行显示最新日期(第4位)在我的示例中排成一行)? Thank you! 谢谢!

在此处输入图片说明

If you only want to see the most recent record, per userID, based on the flightdate, there are a few options. 如果您只想根据排期查看每个用户ID的最新记录,则有几个选项。 The most efficient way is to use a custom SQL command, but Crystal can do it by retrieving all of the records, and then suppressing the records you don't want to see. 最有效的方法是使用自定义SQL命令,但Crystal可以通过检索所有记录,然后隐藏不需要的记录来做到这一点。

1.Group the report by USERID (Report > Group Expert > Add the USERID field to the group section) 1.按USERID对报告进行分组(“报告”>“组专家”>“将USERID”字段添加到“组”部分)

在此处输入图片说明 2. Sort the records by FlightDate ( Report > Sort Expert > Add FlightDate and select Descending NOTE: if FlightDate is not a date, we will need to create a formula to convert it into a date first, otherwise Crystal will treat it as a string and 12/2015 will be higher than 1/2016 (for example) 2.按FlightDate对记录进行排序(“报告”>“排序专家”>“添加FlightDate”,然后选择“降序”。 注意:如果FlightDate不是日期,则需要创建一个公式,首先将其转换为日期,否则Crystal会将其视为字符串)和12/2015将高于1/2016(例如)

在此处输入图片说明

3.Create a running total to count the number of records within each group (This is how we will tell Crystal to suppress the records we don't want) --Right click "running Total" on the right hand side, select New. 3.创建一个运行总计以计算每个组中的记录数(这是我们将告诉Crystal取消不需要的记录的方式)-右键单击右侧的“运行总计”,选择“新建”。 Name it whatever you want; 随心所欲命名 under Field To Summarize add FlightDate, change summary to COUNT Leave Evaluate as "For Each Record" Under Reset, select On Change of Group and select the group for USERID 在“要汇总的字段”下,添加“ FlightDate”,将摘要更改为“ COUNT ”,然后将“求值”保留为“对于每个记录”,在“重置”下,选择“更改组”,然后为USERID选择组

在此处输入图片说明

The report should look like this 该报告应如下所示 在此处输入图片说明

  1. In the Section Expert, select Details and click the formula button next to "Suppress" Enter the formula {#RecountCount} > 1 (Or whatever name your running total has) 在“部分专家”中,选择“详细信息”,然后单击“抑制”旁边的公式按钮。输入公式{#RecountCount} > 1 (或您的运行总计的名称)

Now you should only see one record for each user 现在您应该只为每个用户看到一条记录

在此处输入图片说明

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

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