Crystal Reports 组排序 [英] Crystal Reports group sorting

查看:13
本文介绍了Crystal Reports 组排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有每个用户的航班数据记录.下表显示了一个用户 ID 的示例.我需要按具有最新航班日期的 user_id 进行分组(每个 user_id 只显示一行).

I have flight data records for each user. The table below shows an example for one user id. I need to group by user_id (show only one row for each user_id) that has the latest flight_date.

当我按 user_id 添加分组时,结果报告显示正确的航班日期,但其余字段来自每个用户的最后一行(突出显示的字段).如何让它显示最新的整行日期(在我的示例中为第 4 行)?谢谢!

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)? Thank you!

推荐答案

如果您只想查看每个 userID 的最新记录,基于航班日期,有几个选项.最有效的方法是使用自定义 SQL 命令,但 Crystal 可以通过检索所有记录,然后隐藏您不想看到的记录来做到这一点.

If you only want to see the most recent record, per userID, based on the flightdate, there are a few options. 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.

1. 按 USERID 对报表进行分组(报表 > 组专家 > 将 USERID 字段添加到组部分)

1.Group the report by USERID (Report > Group Expert > Add the USERID field to the group section)

2. 按 FlightDate 对记录进行排序( Report > Sort Expert > Add FlightDate 并选择 Descending 注意:如果 FlightDate 不是日期,我们需要先创建一个公式将其转换为日期,否则 Crystal 会处理它作为字符串,12/2015 将高于 1/2016(例如)

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)

3.创建一个运行总计来计算每个组中的记录数(这就是我们告诉 Crystal 隐藏我们不想要的记录的方式)--右键点击右侧的running Total",选择New.随意命名;在 Field To Summarize 添加 FlightDate 下,将 summary 更改为 COUNT将评估保留为对于每条记录"在重置下,选择 On Change of Group 并选择 USERID 的组

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. 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

报告应如下所示

  1. 在 Section Expert 中,选择 Details 并点击Suppress"旁边的公式按钮输入公式 {#RecountCount} >1(或者你的总和有什么名字)
  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)

现在您应该只看到每个用户的一条记录

Now you should only see one record for each user

这篇关于Crystal Reports 组排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆