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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

supress duplicates in an accumulation formula

Status
Not open for further replies.

chuchuchui

Technical User
Joined
Dec 23, 2004
Messages
33
Location
US
Crystal 11, IBM UniVerse

Accumulation formula references this thread. Which I have at the clients level.

Report function: Display clients without a particular coverage with as much informaiton in one horizontal line.

I work for an insurance agency just so this makes a little more sense. I am getting duplicates when I accumulate the information due to the fact I have to list the drivers and all the policies they have. In some cases there is more than one driver so the policy description gets listed mutliple times, one for each driver. Is there a way to supress these duplicates?
 
Why not do a distinct count of something that is common to them all, such as the policy id.

I tend to not put much effort into posts that don't state example data and expected output, rather trying to describe it.

-k
 
You should have shared the formula you are using. Change your accumulation formula to something like the following:

whileprintingrecords;
stringvar desc;

if instr(desc,{table.desc}) = 0 then
//the above clause allows the description only once
desc := desc + {table.desc} + ", ";

This assumes you have a reset formula and a display formula per customer.

-LB
 
I have the report grouped on our clients.client_id. The details section is supressed. The display information is in the group footer.

What I get currently which is listed horizontally.

Drivers:
TOM ZIP] LISA ZIP] TOM ZIP] LISA ZIP]]
Age:
46, 46, 46, 46
Coverages:
Preferred Auto, Motorcycle, Motorcycle, Preferred Auto,

The preffered output would look like:
Drivers:
TOM ZIP] LISA ZIP]]
Age:
46, 46,
Coverages:
Preferred Auto, Motorcycle,

 
What is your formula? Please paste it(them?) into the thread.

-LB
 
In the supressed details section I have the formula

@accum
whileprintingrecords;
stringvar coverages := coverages + totext({COVERAGES.COVERAGE_DESCRIPTION})+", ";
stringvar drivers := drivers + ProperCase(totext({DRIVERS.DRIVERNAME}))+"] ";
stringvar age := age + totext({@age},0)+", ";

In the group footer I have three formulas

1.) Coverages
@discov
whileprintingrecords;
stringvar coverages;
left(coverages,len(coverages));

2.) Driver Name
@disdrv
whileprintingrecords;
stringvar drivers;
left(drivers,len(drivers));

3.) Age
@disage
whileprintingrecords;
stringvar age;
left(age,len(age));

In the group header is the reset for te formulas in @accum
@reset
whileprintingrecords;
stringvar coverages := "";
stringvar drivers := "";
stringvar age := "";

The age formula
@age
WhileReadingRecords;
DateVar Birth:= {DRIVERS.BIRTHDATE};
DateVar Ann := CurrentDate;

if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1
 
Change the following formula to:

//{@accum}:
whileprintingrecords;
stringvar coverages;
stringvar drivers;
stringvar age;

if instr(coverages,{COVERAGES.COVERAGE_DESCRIPTION}) = 0 then
coverages := coverages + {COVERAGES.COVERAGE_DESCRIPTION}+", ";
if instr(drivers, ProperCase({DRIVERS.DRIVERNAME})) = 0 then (
drivers := drivers + ProperCase({DRIVERS.DRIVERNAME})+"] ";
age := age + totext({@age},0)+", "
);

I removed the totext() around the coverage description and the drivers name, because they are already text (as far as I can see), but maybe there was some reason for using that that I haven't thought of.

You should also add "-2" at the end of each display formula (but within the last paren) to remove the last separator and space, as in:

//{@disage}:
whileprintingrecords;
stringvar age;
left(age,len(age)-2);

-LB

 
Thank you, that worked like it's supposed to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top