Search code examples
crystal-reports

Crystal Reports - concatenating rows based on a field's value


I have a report by a dataset by two master-detail tables (For example, Organizations and Persons).
I have a group section by the master ID.
I want to show the list of the persons in each organization separated by comma in a single row instead of showing each person in a row. How can I do it?


Solution

  • I found out how can I do it.

    I added a group on organizationID.

    Added this formula to the group's header section and suppressed it:

    WhilePrintingRecords;
    StringVar Array reset;
    StringVar Array names:=reset;
    True;  
    

    Added this formula to the detail section and suppressed it:

    WhilePrintingRecords;
    StringVar Array names;
    
    Redim Preserve names[Ubound(names)+1];
    names[Ubound(names)]:={persons.name_field};
    

    Added this formula to the group's footer section:

    //{@display}
    WhilePrintingRecords;
    StringVar Array names;
    Join(names, ",");