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!

Remove duplicate substrings out of a comma delimited string

Status
Not open for further replies.

nilsbinnemans

Programmer
May 14, 2012
14
GB
Hi,

I'm using CR developer 14.0.4.

I have a free text field in my report. There is text imported to the field multiple times and these inputs are delimited with a comma.

Aaaa, Bbbb, Cccc​

However, most of the time these text inputs are just a copy of the previous.

Aaaa, Aaaa, Aaaa​

So my report could contain follow records:
Aaaa, Aaaa, Aaaaa​
Aaaa, Bbbb​
Aaaa, Bbbb, Aaaa​

How could I remove only the duplicates so that it would look like:
Aaaa​
Aaaa, Bbbb​
Aaaa, Bbbb​

Thanks,
Nils
 

Here's one way - it's safer to use an array than just comparing the field to the current string value.

Put this formula in your report header and suppress it - I called it {@DeclareArray}:

Code:
whileprintingrecords;
stringvar array v_array := "Test";
v_array[1]

Then put this formula in your detail section:

Code:
whileprintingrecords;
stringvar array v_array;;

if recordnumber = 1 
then 
v_array[1] := {YourDBField}

else

if {YourDBField} in v_array
 then
("False")
else
 (redim preserve v_array[ubound(v_array) + 1];
 v_array[ubound(v_array)] := {YourDBField});

join(v_array,",");

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top