CONTAINSSTRING
Whether a text contains another, ignoring case, with SEARCH's wildcards (? and *).
Group: Text. Compatible with DAX.
Syntax
CONTAINSSTRING ( <within_text>, <find_text> )
| Parameter | Type | Description |
|---|---|---|
within_text | Text | The text to look in. |
find_text | Text | What to look for. It may hold the wildcards ? and *. |
Returns
Boolean. TRUE when the text holds what is looked for, FALSE when not.
Remarks
- Upper and lower case are the same to it.
?stands for any one character and*for any run of characters. Put~before?,*or~to look for that character itself.- Looking for an empty text gives TRUE in any text that has a character. In an empty or blank text nothing is found, so the result is FALSE.
- A number is turned into text first:
CONTAINSSTRING ( 12345, 23 )is TRUE. - To know where the text is, use
SEARCH; for case to count,CONTAINSSTRINGEXACT.
Examples
Companies that are plants
PLANT in capitals still finds plant.
EVALUATE
FILTER ( Companies, CONTAINSSTRING ( Companies[Company], "PLANT" ) )
ORDER BY Companies[Key]
| Companies[Key] | Companies[Parent] | Companies[Company] |
|---|---|---|
| 11 | 10 | Bergen plant |
| 12 | 10 | Oslo plant |
| 13 | 10 | Trondheim plant |
Wildcards
EVALUATE
ROW (
"b*plant", CONTAINSSTRING ( "Bergen plant", "b*plant" ),
"b?rgen", CONTAINSSTRING ( "Bergen plant", "b?rgen" ),
"A star", CONTAINSSTRING ( "5*3", "~*" ),
"oslo", CONTAINSSTRING ( "Bergen plant", "oslo" )
)
| b*plant | b?rgen | A star | oslo |
|---|---|---|---|
| TRUE | TRUE | TRUE | FALSE |