{unique:ids:delimiter}

Description

Removes duplicate values from a delimited list, keeping the first occurrence of each and preserving order. The input is split on the delimiter (a single dash by default), empty or whitespace-only parts are dropped, and the remaining values are rejoined with the same delimiter. If the input starts with a left square bracket it is treated as a JSON array instead: duplicates are removed and a re-indexed JSON array is returned. Comparison is exact, so values that differ only in surrounding spaces count as different. Commonly wrapped around a collected list of item ids or field values to de-duplicate before counting or displaying them.

Parameters

ids required default (none - required)

The delimited list to de-duplicate. Usually item ids, but any values work (numbers, words, field values). Parts are split on the delimiter; empty or whitespace-only parts are dropped. If the value starts with a left square bracket it is parsed as a JSON array instead.

delimiter optional default - (a single dash); ignored for JSON-array input

The separator between values, used to both split the input and rejoin the result. Defaults to a single dash. Any string works (for example a comma or a comma-and-space). Ignored when the input is a JSON array (a value starting with a left square bracket), which is always split and rejoined as JSON.

Examples

test{unique:a-b-a-c-b}
Expecteda-b-c
Actuala-b-c
The simplest use: split the dash-separated list, keep one copy of each value, rejoin with a dash.
test{unique:3-1-2-1-3}
Expected3-1-2
Actual3-1-2
Order is preserved and the first occurrence of each value is kept; later duplicates are dropped.
test{unique:x-y-z}
Expectedx-y-z
Actualx-y-z
When there is nothing to remove, the list comes back unchanged.
test{unique:red,blue,red,green,blue:,}
Expectedred,blue,green
Actualred,blue,green
The second parameter sets the separator. Here a comma both splits the input and rejoins the result.
test{unique:Prague, Brno, Prague, Plzen:, }
ExpectedPrague, Brno, Plzen
ActualPrague, Brno, Plzen
A multi-character delimiter works too. Here the separator is a comma followed by a space.
test{unique:a--b-a-}
Expecteda-b
Actuala-b
Empty and whitespace-only parts (here from the doubled and trailing dashes) are removed before de-duplicating.
test{unique:["a","b","a","c"]}
Expected["a","b","c"]
Actual["a","b","c"]
When the input starts with a left square bracket it is parsed as a JSON array; a de-duplicated, re-indexed JSON array is returned. The delimiter is ignored in this mode.
test{count:{unique:red-blue-red-green-blue}}
Expected3
Actual3
The common real-world pattern: wrap unique to drop duplicates, then count what is left. In production the inner list is usually collected from items, for example {count:{unique:{item:{ids:SLICE}:FIELD:-}}} to count distinct field values.
test{unique:a- a-a}
Expecteda- a
Actuala- a
Comparison is exact and parts are not trimmed: "a" and " a" (with a leading space) are treated as two different values, so neither is removed.