Function overview
Prototype
deDup (
text; separator )
Parameters
text The text that you would like to de-duplicate
separator The text that separates text items
Description
Tags:
unique values remove duplicates deduplicate de-duplicate
De-duplicates text which is separated by a delimiter - e.g. you might have a value list that needs de-duplicating.
Reviewing this now - this might only work for valueLists - think you will need to change first part of Let function to deal with non-value list text... haven't tested. Will test one day & update.
Examples
Sample input
deDup( List( table::field ) ; ¶ )
Sample output
This will give you a list will all the duplicates removed
Function code
Let(
[
text = Substitute( text ; [ separator ; ¶ ] ) ;
value = GetValue( text ; 1 ) ;
count = ValueCount( text ) ;
sep = "@|$|@" ;
text = Replace ( Substitute ( ¶ & text & ¶ ; [ ¶ ; ¶ & sep ] ; [ sep & value & ¶ ; "" ] ; [ sep ; "" ] ) ; 1 ; 1 ; "" ) ;
next = If( count > 0 ; deDup( Replace( text ; Length( text ) ; 1 ; "" ) ; separator ) )
] ;
If( count > 0 ; value & If( Length( next ) > 0 ; separator & next ) )
)
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/235
Prototype: deDup( text; separator )
Function Author: Charlie (http://www.fmfunctions.com/mid/132)
Last updated: 02 March 2011
Version: 2.0
*/
// ===================================
Let(__LITBR__[__LITBR__text = Substitute( text ; [ separator ; ¶ ] ) ;__LITBR__value = GetValue( text ; 1 ) ;__LITBR__count = ValueCount( text ) ;__LITBR__sep = "@|$|@" ;__LITBR__text = Replace ( Substitute ( ¶ & text & ¶ ; [ ¶ ; ¶ & sep ] ; [ sep & value & ¶ ; "" ] ; [ sep ; "" ] ) ; 1 ; 1 ; "" ) ;__LITBR__next = If( count > 0 ; deDup( Replace( text ; Length( text ) ; 1 ; "" ) ; separator ) )__LITBR__] ;__LITBR____LITBR__If( count > 0 ; value & If( Length( next ) > 0 ; separator & next ) )__LITBR____LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/235__LITBR____LITBR__ Prototype: deDup( text; separator )__LITBR__ Function Author: Charlie (http://www.fmfunctions.com/mid/132)__LITBR__ Last updated: 02 March 2011__LITBR__ Version: 2.0__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.