Replace duplicate entries in list @Formula

I’ve search the forum and tried various @formulas, but still can’t figure out how to do this…

I have a list with values, eg. “A” : “A” : “B” : “C” : “C” : “C” : “D”

and want to replace the duplicate entries with an empty string, but keep the first duplicate entry:

i.e. “A” : “” : “B” : “C” : “” : “” : “D”

Any suggestions?

Subject: Replace duplicate entries in list @Formula

Refer my other post —> “Here is the solution”

Subject: Replace duplicate entries in list @Formula

Try @Unique.

/Peter

Subject: Replace duplicate entries in list @Formula

FIELD dlist := dlist;list := “A” : “A” : “B” : “C” : “C” : “C” : “D”;

temp := list[1];

nl := temp;

@For(n := 2; n <= @Elements(list); n := n + 1;

@If(list[n] = temp; nl:=nl:" ";@Do( temp := list[n]; nl:=nl:temp))

);

@SetField (“dlist”; nl)

Subject: RE: Replace duplicate entries in list @Formula

Thanks Sergei, your code works great!

Subject: Replace duplicate entries in list @Formula

Gary,

Will @Unique not do what you want?

Why do you need to keep empty entries where the duplicates were?

Mike

Subject: RE: Replace duplicate entries in list @Formula

I’ve tried @Unique but I need to replace the duplicate entries with blank entries. What I’m trying to accomplish is to generate headings on a web page for documents using @DBlookups.

I have say 4 docs with the following fields

docA, Heading1

docB, Heading1

docC, Heading2

docD, Heading3

I do the following @DBLookups

List1 = “docA” : “docB” : “docC” : “docD”

List2 = “Heading1” : “Heading1” : “Heading2” : “Heading3”

I want to be able to display the lists in the following format

Heading1

docA

docB

Heading2

docC

Heading3

docD

Currently the following format is displayed:

Heading1

docA

Heading1

docB

Heading2

docC

Heading3

docD

I’m currently investigating other ways of getting the required format, but if I can replace unique entries with empty strings it will do what I want.

Hope I’ve explained what I’m trying to do - thanks for your previous responses.

Subject: Here is the solution

lst := “A” : “A” : “B” : “C” : “C” : “C” : “D”;

@For(n := 1; n <= @Elements(lst); n := n + 1;

tmp := @Subset(@Subset(lst; n);-1);

@If(n = 1; tmp1 := tmp; tmp1:= tmp1: @If(@IsMember(tmp; tmp1); “~”; tmp))

);

tmp1

tmp1 will be the result as A; ~; B; C; ~;~;D

If you remove ~ you will have spaces instead.