How to show multiple unrelated 1:N records in Crystal
I have a data set that I am reporting on. However, some of the data is duplicated and some is not:
ID Project Org Type Facility AssessorManager Assessor
123 Proj1 Org1 Ty1 Facil1 Smith Jones
123 Proj1 Org2 Ty1 Facil2 Smith Black
123 Proj1 Org2 Ty1 Facil3 Smith Black
234 Proj1 Org3 Ty2 Facil3 Harris Jones
234 Proj1 Org1 Ty2 Facil3 Harris Jones
393 Proj2 Org2 Ty3 Facil1 Smith Black
So, for an ID, there is a 1:1 relationship with the Project, Type, and AssessorManager; and a 1:N relationship with the Org, Facility, and Assessor.
I want a report that doesn't repeat more than necessary, and have reported the 1:1 data, and then stored procedures for each of the 1:N data sets. I get a result like below, but it is dog SLOW.
ID Project Org Type Facility AssessorManager Assessor
123 Proj1 Org1 Ty1 Facil1 Smith Jones
Org2 Facil2 Black
Facil3
234 Proj1 Org3 Ty2 Facil3 Harris Jones
Org1
393 Proj2 Org2 Ty3 Facil1 Smith Black
Can I make a function for the 1:N fields that orders the data and shows distinct data? I can use the suppress if duplicated option for the field, but 开发者_如何学JAVAI need to sort each field within the ID on its own. I can't use group by and set groups, because there are 4 1:N fields, and they are all independent of each other.
(Doing the group by in the past has resulted in a report that looks like the following:
ID Project Org Type Facility AssessorManager Assessor
123 Proj1 Org1 Ty1 Facil1 Smith Jones
Black
Facil2 Jones
Black
Facil3 Jones
Black
Org2 Facil1 Jones
Black
Facil2 Jones
Black
Facil3 Jones
Black
...etc.)
EDIT... answer... I accepted PowerUser's answer, mostly using his second suggestion. I added fields to my query. It still had duplication, because some of the 1:N fields were query and sort fields. There is probably more duplication than shown here, but this is the idea. Also, rather than using commas to separate the values in the memo fields, I used a return character.
ID Project Org Orgs Type Facility Facilities AssessorManager Assessors
123 Proj1 Org1 Org1,Org2 Ty1 Facil1 Facil1,Facil2,Facil3 Smith Jones,Black
123 Proj1 Org2 Org1,Org2 Ty1 Facil2 Facil1,Facil2,Facil3 Smith Jones,Black
123 Proj1 Org2 Org1,Org2 Ty1 Facil3 Facil1,Facil2,Facil3 Smith Jones,Black
+1 for your examples! So let me get this straight. It works, but you want it to work faster?
- In your 3rd example table, I think you're using a Helper (aka Index) table and right joining to your data. That would explain why you have a row for
Proj 1, Org 1, Black
when there is no record in your original data set. Inner joining would fix that, but make sure it doesn't produce any other problems in the process. - Instead of grouping by ID, then Proj, the Org, etc., you can make a single concatenated field for grouping, i.e.
GroupBy=[ID]&[Proj]&[Org]
. That will speed things up a bit since you only have 1 grouping level. - Based on your tags, i believe your datasource is SQL Server 2008. If you are pulling from a query, try making a temporary static table instead. That will simplify things considerably for Crystal.
(If one of these suggestions is helpful, please tell me which one.)
精彩评论