Skip to Content

Combine a set of data in multiple rows to show into one row in Crystal Reports

Good afternoon.

I frequently need to do this and I have not figured it out. I am really close, but I am still stumbling across duplicated data....

The data:

Table 1: Acct Number is the primary indicator

Table 2: Sub Acct#1 (there could be up to 20 types)

Table 3: Sub Acct#2 (there could be up to 40 types)

I need the finished row to be:

12345 (field1) 000, 001,002 (field 2) 610, 620, 841 (field 3)

If that is not possible then:

12345 (field 1) 000, 001, 002, 610, 620, 841 (field 2)

What I am currently experiencing is:

(there is duplication of 000 & 611)


*I created a group by account numbers

Formulas:

Group Header:

whileprintingrecords;
stringvar names := "";

Details: (2 separate formulas, both placed on detail line)

whileprintingrecords;
stringvar names;
names := names & ", " & {@Share Type 3 Digits};

whileprintingrecords;
stringvar names;
names := names & ", " & {LoansCombinedEOM.Account Type};

Group Footer

whileprintingrecords;
stringvar names;
Mid(names, 3);

Thank you,

Shanna

gk8bw.png (445 B)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 15 at 07:46 AM

    Hi Shanna,

    You can combine the two formulas on the details into a single formula with this code:

    whileprintingrecords;
    stringvar names;
    names := If Instr(names, {@Share Type 3 Digits}) > 0 then names Else names & ", " & {@Share Type 3 Digits};
    names := If Instr(names, {LoansCombinedEOM.Account Type}) > 0 then names Else names & ", " & {LoansCombinedEOM.Account Type};

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded