OpenBI Docs Buy

SEARCH

Where a text first appears in another, ignoring case and width, with ? and * wildcards; a value of your choice, or an error, when it doesn't.

Group: Text. Compatible with DAX.

Syntax

SEARCH ( <find_text>, <within_text> [, <start_num>] [, <NotFoundValue>] )
ParameterTypeDescription
find_textTextWhat to look for. It may hold the wildcards ? and *.
within_textTextThe text to look in.
start_numWhole number
optional
The character to start looking from; 1, the first, when left out.
NotFoundValueValue
optional
What to return when nothing matches, often 0 or BLANK (). Left out, that is an error.

Returns

Whole number. The position where the first match begins, counting from 1.

Remarks

  • Upper and lower case are the same to it, and so are full-width letters and ordinary ones. For case to count, use FIND.
  • ? stands for any one character and * for any run of characters; ~ before one of them, or before ~, looks for that character itself.
  • The position counts from the start of the text, wherever the search began.
  • When nothing matches and no NotFoundValue is given, the result is an error.
  • A start below 1 is an error; a start past the end finds nothing. An empty find_text is found at position 1 of any text that is not empty.

Examples

Case does not count

EVALUATE
ROW (
    "plant", SEARCH ( "plant", "Bergen Plant" ),
    "e from the 3rd", SEARCH ( "e", "Bergen", 3 )
)
plante from the 3rd
85

Wildcards

EVALUATE
ROW (
    "pl?nt", SEARCH ( "pl?nt", "Oslo plant" ),
    "g*t", SEARCH ( "g*t", "Bergen plant" ),
    "A star", SEARCH ( "~*", "5*3" )
)
pl?ntg*tA star
642

When it is not there

EVALUATE
ROW (
    "0", SEARCH ( "x", "abc", 1, 0 ),
    "Blank", SEARCH ( "x", "abc", 1, BLANK () )
)
0Blank
0(blank)

FIND, CONTAINSSTRING, MID, SUBSTITUTE, REPLACE.

Last updated · OpenBI Studio 0.3.74