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!

Indicating duplicate items on sorted list

Status
Not open for further replies.

nikitty

Programmer
Jun 29, 2010
2
CA
I have a list of activities that I want sorted by date. I need some way of indicating the duplicates on the list while still keeping the sort order. I notice that if I sort the activities and then use the previous() function to compare entries, I can partly achieve what I want. Is there a similar function that I can use to compare all previous activities in a list so I can indicate which ones are duplicates?

Thanks in advance,

Nicole
 
You will need to build an array adding each unique entry, and then compare each new record with the array. An array is limited to 1000 elements so will restrict the size of the report.

Ian

 
If there are not too many activities, you could do a running total for each, note when it is greater than 1.

If you're not already familiar with Crystal's automated totals, see FAQ767-6524.


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Ian is on the right track by using an array but you will need to build your array in a subreport in the report header or else the first instance of a duplicated field will not be counted as a duplicate i.e.

john unique
jane unique
john duplicate

so you will need to add a subreport that creates an array containing all of the values that you want to test aginst

Add a group to your subreport on the field that you want to test against and in the group header section add a formula like

Code:
Shared StringVar Array UniqueTest;

If Count({TestField}, {TestField}) > 1 Then
   (Redim Preserve UniqueTest[Ubound(UniqueTest) + 1];
    UniqueTest[Ubound(UniqueTest)] := {TestField});
0

Then in your main report you can use this array to test to see if your value is unique i.e.

Code:
Shared StringVar Array UniqueTest;

If {TestField} In UniqueTest Then
   'Duplicate'
Else
   'Unique'

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Thanks so much for your replies. I got it to work using arrays :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top