csl_take(X;Y)
Returns the first number of elements in a given comma-separated list.
Syntax
csl_take(X;Y)
Input
Argument | Type | Description |
---|---|---|
X |
text | A comma-separated list or the name of a column containing a comma-separated list |
Y |
integer | The index of an element within the comma-separated list |
Return Value
Returns a comma-separated list consisting of the first
Y
elements in the
comma-separated list X
. The index is 1-based (e.g., the first two elements
in the list are returned when Y
=2).Note: A negative
index counts back from the end of the list (e.g.,
Y
=-2 returns the last two element in the
list).If X
is N/A, the result is N/A.
If |Y
| is greater than the number of elements in the list, the result is
X
.
Sample Usage
csl_list |
index |
csl_take(csl_list;index) |
---|---|---|
'dog,cat,bird,horse,hippo,duck' | 2 | 'dog,cat' |
'dog,cat,bird,horse,hippo,duck' | -2 | 'hippo,duck' |
'dog,cat,bird,horse,hippo,duck' | 15 | 'dog,cat,bird,horse,hippo,duck' |
'dog,cat,bird,horse,hippo,duck' | -15 | 'dog,cat,bird,horse,hippo,duck' |
'' | 2 |