beginswith(X;L)

Returns a boolean value indicating whether a given string begins with any of the substrings in a given list.

Syntax

beginswith(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 begins 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 beginswith(value;list)
'banana' 'abc' 'ban' '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 start with either "96" or "3B". To do this, create a computed column and apply the beginswith(X;L) function to the sku column, where L is the list containing the strings '96' and '3B':
<base table="pub.demo.retail.item"/>
<willbe name="example" value="beginswith(sku;'96' '3B')"/>

For those values in the sku column that begin with "96" or "3B", 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 3B7, 969, or 96A.