endswith(X;L)
Returns a boolean value indicating whether a given string ends with any of the substrings in a given list.
Syntax
endswith(X;L)
Input
Argument | Type | Description |
---|---|---|
X |
text | The string to search for in the items in the list L A scalar value or the name of a column |
L |
text | A space- or comma-separated list of text strings against which to compare
X |
Return Value
Returns an integer value of 1 if X
ends with any of the strings in the
list L
. Otherwise, returns 0.
If X
is N/A, the result is 0.
Sample Usage
value |
list |
endswith(value;list) |
---|---|---|
'banana' | 'abc' 'ana' 'yz' | 1 |
'banana' | 'abc' 'yz' | 0 |
Example
In the "Sales Item Detail" table (pub.demo.retail.item), you can find
only those rows whose SKUs end with either "6" or
"9". To do this, create a computed column and apply the
endswith(X;L)
function to the sku
column, where
L
is the list containing the strings '6'
and
'9'
.
<base table="pub.demo.retail.item"/> <willbe name="example" value="endswith(sku;'6' '9')"/>
For those values in the sku
column that end with
"6" or "9", the result is
1.
Otherwise, the result is 0.
You could then use the <sel>
operation to select only those rows where the
example
column equals 1.
<sel value="(example=1)"/>
The results are those rows where the value in the sku
column is
366, 969, or
A96.