R – Flatten data inside a crystal report

crystal-reports

Ok, this might be a weird request, but is it possible to essentially flatten my dataset inside a crystal report?

I have a datatable in C# that was created with a join, so when it hits the report its 2 records. Most of the columns have identical data, with the last few displaying a different address.

Instead of printing the detail section multiple times with mostly similar data, I need to display 1 'record' with the common data printed once, and each records address arranged next it. As in, all the common fields displayed in one area, and then next to that the address fields from the record where 'AddressType = 1', then next to that the address fields where 'AddressType = 2'

Is this a subreport thing? Because even with subreports I can't get it to only print 1 detail section with the data from just the first record.

Is this even possible with crystal? For long drawn out reasons, I can't flatten the data before it gets to the report.

Best Answer

Ok, someone here in the office showed me the way, so I'll put this out there.

Given data with cols A,B,C all common and D,E different across multiple rows, this is how I 'flattened' the dataset in crystal:

  1. Create a group based on col A, and put A,B,C inside that group header - get rid of the details section entirely
  2. Create a subreport in the group header for each row of data, in my case 2 subreports
  3. Inside each subreport, put fields D,E. Important: There are NO links for these subreports!
  4. For each subreport go into the Select Expert and create a condition that shows only 1 particular row of data. This conditional will have the same field for each subreport, but different values. In my case it was AddressType='A', and AddressType='B'

This will produce 1 report, with A,B,C listed once, and D,E listed once for each subreport(once for each row of data)

This was confusing, time consuming, and I hate crystal reports now more than ever.

Related Topic