Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: display first record in footer - three formula Post Reply Post New Topic
Author Message
Andrewarbogast
Newbie
Newbie
Avatar

Joined: 21 Aug 2017
Location: United States
Online Status: Offline
Posts: 39
Quote Andrewarbogast Replybullet Topic: display first record in footer - three formula
    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;
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.