Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare details in two group

Status
Not open for further replies.

dnamm

Programmer
Jul 16, 2003
8
0
0
US
Hi All,

I'm currently using Crystal Report version 8.5.
I need help in comparing the detail fields on one record (group level) with the details of the next record.
ex: I have this ClaimNo as the group field. I want to display only claims that have one or more detail fields that is the same as in the next claim.
There will be only 2 ClaimNo to be compared within a bigger group.
ClaimNo: 123456789 987456321
details: 0001 0004
0003 0005
0005 0010
1111
The above are the claimNo that I would like to display on my report because they have the at least one details field that is the same (0005).

Thank you!
 
Not really clear what you're trying to do, you're generally best served to provide basic technical information when posting:

Crystal version
Database/connectivity used
Example data
Expected output

If you want to compare a value to a vcalue in the next row, try:

If {table.field1} = next({table.field1})
and
{table.field2} = next({table.field2})
then
"some action"
else
"another action"

There is also a PREVIOUS function for examining/comparing the previous rows data.

-k
 
Thanks Synapsevampire,

My Crystal Report version is 8.5, connecting to SQL Server 7.0.
I'm trying to display those claimNo that have at least one proccode (details level) that is the same as the next claimNo. There are only two claimNo will be compared,
because these claimNo group is within another bigger group (MemberID).
Example: In one claimNo, we can have one or multiple proccodes. If the first claimNo have at least one proccode that is the same as the second claimNo, then I would like to display both of it. The proccode is the detail of each claimNo.
The first ClaimNo = 2004071600009
proccode:
11112
11113
11114
11119
The second ClaimNo = 2004071600056
proccode:
56984
56324
11119

My output will be:
ClaimNo: 2004071600009
proccode:
11112
11113
11114
11119
ClaimNo: 2004071600056
proccode:
56984
56324
11119

Note: The number of proccode in each claimNo will not always equal. We can't access proccode1 or proccode2 since there is only one field name is proocode.
Thank you very much!

dnamm


 
I think you will have to use a subreport. In the main report, you have a group#1 on {table.MemberID} and then a group#2 on {table.claimno}. Insert a subreport and create the same group structure, with proccode in the detail section. In the subreport, create the following formulas:

//{@resetx} to be placed in the subreport group #1 header:
whileprintingrecords;
stringvar x := "";

//{@resety} to be placed in the subreport group #2 header:
whileprintingrecords;
shared numbervar y := 0;

//{@accum} to be placed in the subreport details section:
whileprintingrecords;
stringvar x;
shared numbervar y;

if instr(x,{table.proccode}) = 0 and
{#cntwingrp} = 1 then
x := x + {table.proccode} else x := x;
if instr(x,{table.proccode}) <> 0 and
{#cntwingrp} = 2 then
y := 1;
y;

//where {#cntwingrp} is a running total using the running total expert. Select {table.claimno}, distinctcount, evaluate for each record, reset on change of group (Member ID).

//{@shared var y} to be placed in the subreport group #2 (Claim No) footer:
whileprintingrecords;
shared numbervar y;

Suppress all sections within the subreport and place the subreport in the group #1 header of the main report. Then go to the section expert (format->section)->for each of the Group Header #2, Details, and Group Footer #2->suppress->x+2->enter the following:

whileprintingrecords;
shared numbervar y = 0;

If you want to suppress the member group, add this formula into the suppression formula area for the group header #1 and group footer #1.

You can resize the subreport to be as small as possible and also format it to remove the borders.

-LB
 
>>>There are only two claimNo will be compared.

If there is a way to group these two claims together (ie if they have something in common or if they are the only claims in the report) you may be able to check for the match in a cross-tab at the beginning of the group/report and use a variable in the cross-tab to flag whether the items should print or not.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- TEK2(AT)kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top