Search code examples
crystal-reports

How to add subgrups on Crystal Reports


I'm trying to add a subgroup to my report, I have 5 columns: 1. customer code 2. customer name 3. transaction type 4. transaction description 5. transaction amount

Transaction type must be a subgroup, this value comes from the database, usually it's type A or B, sometimes it has type C.

The first group it's the customer code, it will look like a header, then the transaction type will form 2 or 3 columns, bellow the transaction description with the transaction amount.

Customer Code: C001
Transaction Type
A B
Description Amount Description Amount
Purchase A1 $10 Purchase B1 $5
Purchase A2 $15 Purchase B2 $7
Purchase B3 $9
Purchase B4 $11

I have tried adding Groups but the information goes downwards.

Customer Code: C001
Transaction Type: A
Description: Purchase A1
Amount: $10
Description: Purchase A2
Amount: $15
Transaction Type: B
Description: Purchase B1
Amount: $5
Description: Purchase B2
Amount: $7
Description: Purchase B2
Amount: $9
Description: Purchase B2
Amount: $11


Solution

  • Try this (maybe some adjustments will be needed):

    1. Main report: Group by customer code
    2. In details section, create two subreports and place them side by side. Let's call them subreport A and subreport B.
    3. Create subreports links on both subreports, using the customer code.
    4. Create columns "Description" and "Amount" on both subreports (fields on details).
    5. On subreport A, hide detail section when transaction type is not "A".
    6. On subreport B, hide detail section when transaction type is not "B".

    You said that the transaction type can be "C", but you didn't said what is supposed to happen in this case. Would it be another column? But I think you can figure out how to deal with it.