Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formula Quirk in Group Footer Post Reply Post New Topic
Author Message
bshort1023
Newbie
Newbie
Avatar

Joined: 18 Jan 2012
Location: United States
Online Status: Offline
Posts: 18
Quote bshort1023 Replybullet Topic: Formula Quirk in Group Footer
     Posted: 01 Jul 2014 at 3:20am
The following formula is designed to take one piece of text (ResourceGrpID) from each detail record and concatenate them to show in one field in the group footer section.  It works with one exception.  When I put the formula on the report in the group footer it takes the last piece of data and duplicates it so I get the last piece of data twice.  I have tried everything I can think of.  If I put the formula in the detail section (which I do not show on the report) it looks correct.

Thanks for any help,

Bill

STRINGVAR ResourceList;

// First record on the report
IF GroupNumber =1 AND RecordNumber = 1 THEN ResourceList := {BAQReportResult.JobOpDtl.ResourceGrpID}
ELSE
//  Not the first record on the report but 1st op on this job
    IF {BAQReportResult.JobOper.JobNum} <> PREVIOUS({BAQReportResult.JobOper.JobNum}) THEN
        ResourceList := {BAQReportResult.JobOpDtl.ResourceGrpID}
//  Another op on the same job
    ELSE
        IF ResourceList = "" THEN
            ResourceList := {BAQReportResult.JobOpDtl.ResourceGrpID}
        ELSE
            IF {BAQReportResult.JobOper.OprSeq} = PREVIOUS({BAQReportResult.JobOper.OprSeq}) THEN
                ResourceList
            ELSE
                ResourceList := ResourceList + ", " + {BAQReportResult.JobOpDtl.ResourceGrpID};

Example of result:  2900, 3300, 3050, 3050
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 01 Jul 2014 at 4:41am
Create 3 formula's:

//Place this one in your group header
shared stringvar ResourceList;
ResourceList := '';

//Place this one in your detail section
whileprintingrecords;
shared stringvar ResourceList;
if not IsNull({BAQReportResult.JobOpDtl.ResourceGrpID}) then
(
    if (ResourceList = '') then
        ResourceList := ResourceList + {BAQReportResult.JobOpDtl.ResourceGrpID}     
    else
        ResourceList := ResourceList + ', ' + {BAQReportResult.JobOpDtl.ResourceGrpID}
)

//Place this one in your group footer
shared stringvar ResourceList;
ResourceList
IP IP Logged
bshort1023
Newbie
Newbie
Avatar

Joined: 18 Jan 2012
Location: United States
Online Status: Offline
Posts: 18
Quote bshort1023 Replybullet Posted: 01 Jul 2014 at 9:34am
That is perfect.  Thank you very much.

Any chance you could explain the logic behind what gets placed in the header, detail, and footer sections?  I am assuming that was a big part of my problem.

IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 01 Jul 2014 at 9:11pm
The formula in the group header works as a reset. This makes sure every group starts clean.

The detail section is checking if it has a value. If it does, it checks the original formula. If is already has a value, it is using the formula, adds a comma and then your database field. Otherwise it is just using your database field. Without this small little check, your formula would start with the comma.

The footer is just showing the current value of the formula. It needs the detail part, to get all the values from that group, and the header part to make sure it is for this group only.

Does this answer your question?
IP IP Logged
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