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>] )
| Parameter | Type | Description |
|---|---|---|
find_text | Text | What to look for. It may hold the wildcards ? and *. |
within_text | Text | The text to look in. |
start_num | Whole number optional | The character to start looking from; 1, the first, when left out. |
NotFoundValue | Value 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 )
)
| plant | e from the 3rd |
|---|---|
| 8 | 5 |
Wildcards
EVALUATE
ROW (
"pl?nt", SEARCH ( "pl?nt", "Oslo plant" ),
"g*t", SEARCH ( "g*t", "Bergen plant" ),
"A star", SEARCH ( "~*", "5*3" )
)
| pl?nt | g*t | A star |
|---|---|---|
| 6 | 4 | 2 |
When it is not there
EVALUATE
ROW (
"0", SEARCH ( "x", "abc", 1, 0 ),
"Blank", SEARCH ( "x", "abc", 1, BLANK () )
)
| 0 | Blank |
|---|---|
| 0 | (blank) |