Print Page | Close Window

display first record in footer - three formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22647
Printed Date: 24 Apr 2024 at 6:24pm


Topic: display first record in footer - three formula
Posted By: Andrewarbogast
Subject: display first record in footer - three formula
Date Posted: 23 Jul 2018 at 6:27am
Hello everyone,
I received a report that was built by someone else and I was wondering how a series of formulas work. So the report shows first billable date of contact in the footer. I'm just trying to get a better understanding of how this works. Thanks so much.

It looks like it works through a series of three formulas:

1. Header (suppressed)- whileprintingrecords;

datevar FirstContact;

if not(inrepeatedgroupheader) then
   FirstContact:= date(1900,01,01);


2. Details(suppressed) - whileprintingrecords;

datevar FirstContact;

if FirstContact = date(1900,01,01) then
   if {billing_tx_history.SERVICE_CODE} like ["700","999","400","420","440","450","90804","90806","90808","90832","90834","90837","H0004BH","H2019","H2019HN",
"H2019HO","H0036","H0036PH"] then
      FirstContact:= {billing_tx_history.date_of_service};


3. Footer - whileprintingrecords;

datevar FirstContact;



Replies:
Posted By: DBlank
Date Posted: 24 Jul 2018 at 4:35am
basically this "executes" in the order of the report sections top to bottom (while printing records).
Part 1, the GH part, is setting up the variable value to = 1/1/1900 every time any group starts. It has an extra clause to avoid doing this on a repeated group header if the group is being displayed on more than one page. If the group header was not being displayed on each page this should not be needed.
Step 2 on the detail row it is looking to see if the current value of the variable is 1/1/1900. If it is not it is presuming that it already identified the 'correct' date for the group on a previous detail row so it does nothing other than leaving the existing date value in the variable (for that group).
If it finds the 1/1/1900 value then it wants to analyze that row for another condition of specific billing codes. If that row has that code then it sets the variable to the date from that row. IF not it does nothing and moves to the next row and tries again.
Step 3 displays the result for that group in the group footer. Then on the following group the group header sets the value back to 1/1/1900 and it starts all over again for the next group.
Basically it is 'scanning' the rows from first to last, per group, and trying to find the first row in that group that has a code from a specific list in it
and then display the related date of service from that row for the group.



Print Page | Close Window