Print Page | Close Window

Report first record for each test

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22779
Printed Date: 29 Apr 2024 at 1:19am


Topic: Report first record for each test
Posted By: Beaster
Subject: Report first record for each test
Date Posted: 28 May 2019 at 10:58am
Hello all,

I'm putting together a report that will ultimately be exported to CSV. Each product can go through a series of tests, and these tests may or may not be repeated. Test 1 must pass before test 2 is performed, and so on.

Here's an example of what I have:

Barcode      Test Name      Test Result
Barcode1      Test1           Result1
Barcode1      Test1           Result2
Barcode1      Test2           Result3
Barcode1      Test2           Result4
Barcode1      Test3           Result5
Barcode2....

And so on for each product barcode. Ultimately, I want each barcode to only have 1 line with all tests listed. The report would end up looking like this:

Barcode      Test1      Test2      Test3
Barcode1   Result2    Result4   Result5
Barcode2...
with only the most recent test result for each test showing, listed horizontally.

Not shown in the example is a testing date, and I've sorted in descending order so that the newest result is always listed first. I also currently have the report grouped by barcode which seems like a logical step. However, I'm not sure where to go from here. Any help or suggestions on how to approach this are appreciated!



Replies:
Posted By: Beaster
Date Posted: 03 Jun 2019 at 10:30am
I was able to solve this using subreports and shared variables.

1) Create 3 copies (1 for each test) of the main report to be used as subreports.
2) In the subreports, update the record selection formulas to select records based on test names.
3) Create shared variables for Test1, Test2, and Test3 results in their respective subreports and the main report.
4) Insert all the subreports into the details section of the main report. Subreports can be linked to main report using barcode field.
5) Place shared variables in the group footer. They should display the proper results.
6) Add barcode and other relevant database fields to group footer.

After tweaking settings related to exporting CSV files, results are as desired. If there's an easier/better way to do this, feel free to let me know.



Print Page | Close Window