SEARCH Function (DAX)

How does the SEARCH function (DAX) work?

The SEARCH function (DAX) returns the number of the character at which a specific character or text string is first found, reading left to right. Search is case-insensitive and accent sensitive.

SEARCH Formula Syntax

SEARCH (
     <find_text>, <within_text>, [<start_num>] [, <NotFoundValue> ]]
)

How do you use the SEARCH function?

  1. The search function is case insensitive. Searching for “N” will find the first occurrence of ‘N’ or ‘n’.
  2. The search function is accent sensitive. Searching for “á” will find the first occurrence of ‘á’ but no occurrences of ‘a’, ‘à’, or the capitalized versions ‘A’, ‘Á’.
  3. By using this function, you can locate one text string within a second text string, and return the position where the first string starts.
  4. You can use the SEARCH function to determine the location of a character or text string within another text string, and then use the MID function to return the text, or use the REPLACE function to change the text.

Related Blog Posts

Related Support Forum Posts

Multiple condition text search criteria
Curriculum search
Searching a value in another table

Considerations when using the SEARCH function

If the find_text cannot be found in within_text, the formula returns an error. This behavior is like Excel, which returns #VALUE if the substring is not found. Nulls in within_text will be interpreted as an empty string in this context.

Related Video Tutorials

Formula examples using the SEARCH function

=SEARCH(“n”,”printer”)

=SEARCH(“-“,[PostalCode])

= IFERROR(SEARCH(“-“,[PostalCode]),-1)= IFERROR(SEARCH(“-“,[PostalCode]),-1)

Related DAX Functions

REPLACE

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

DOWNLOAD


Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.


Download DAX Formula Reference Guide