Dax Function: FIND
Category: Text Functions
The FIND function in Power BI is a DAX function that locates the starting position of a specific substring within a text string. It performs a case-sensitive search and returns the numeric position of the first occurrence of the substring.
Purpose
To determine the position of a substring in a larger text string for further text manipulation or validation.
Calculations Performed
The function calculates the numeric position of a substring within a text string, enabling targeted operations like extracting, replacing, or validating text data.
Practical Use Cases
- Locating delimiters or specific keywords in text strings.
- Splitting or extracting parts of a text string based on the position of substrings.
- Validating whether a specific word or character exists in a given text.
FIND(find_text, within_text[, start_position])
| Parameter | Type | Description |
|---|---|---|
| find_text | Text/Scalar | The text string to find. This parameter is case-sensitive. |
| within_text | Text/Scalar | The text string in which to search for find_text. |
| start_position | Numeric/Scalar | (Optional) The position to start the search. Defaults to 1 (start of the string). |
How Does FIND Dax Function Works
The FIND function operates as follows:
- Searches for the
find_textsubstring inwithin_textstarting at the specifiedstart_position. - If the substring is found, it returns the position (1-based index) of the first character in the substring.
- If the substring is not found, the function throws an error.
What Does It Return?
The function returns an integer:
- The numeric position of the first occurrence of
find_textinwithin_text. - Returns an error if
find_textis not found or if the starting position exceeds the string length.
When Should We Use It?
- Text Parsing: Extracting specific parts of a text based on delimiter positions.
- Validation: Checking the existence and position of certain keywords or characters in a string.
- Conditional Logic: Using the position result to implement conditional processing or formatting.
Examples
Basic Usage
Locating the position of a substring in a text string.
FIND("Power", "Power BI is great")
Result: 1 (substring starts at position 1).
Column Usage:
Finding the position of a specific character in a column of text.
FIND("@", 'Emails'[EmailAddress])
Result: A column containing the position of the “@” symbol in each email address.
Advanced Usage
Combining with other functions for text extraction.
MID('Emails'[EmailAddress], FIND("@", 'Emails'[EmailAddress]) + 1, LEN('Emails'[EmailAddress]))
Result: Extracts the domain part of email addresses.
Tips and Tricks
- Error Handling: Use
IFERRORto handle scenarios wherefind_textis not found.IFERROR(FIND("Power", "BI Tools"), 0)
This returns0instead of an error if the substring is not found. - Case Sensitivity: If a case-insensitive search is required, consider using
SEARCHinstead ofFIND. - Optimize Start Position: When searching for multiple substrings, adjusting the
start_positioncan improve performance.
Performance Impact of FIND DAX Function:
- On large datasets, use the
start_positionparameter to minimize the search range and improve performance. - Avoid excessive nesting of text functions for complex transformations to maintain readability and efficiency.
Related Functions You Might Need
- SEARCH: Similar to FIND but performs a case-insensitive search.
- MID: Extracts a substring starting at a specific position.
- LEN: Returns the length of a text string.
- SUBSTITUTE: Replaces occurrences of a substring in a text string.
Want to Learn More?
For more information, check out the official Microsoft documentation for FIND You can also experiment with this function in your Power BI reports to explore its capabilities.
Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.
The FIND function returns the position of a specified substring within a text string, performing a case-sensitive search.
Yes, the FIND function is case-sensitive. For case-insensitive searches, use the SEARCH function.
The FIND function returns an error if the substring is not found.
Yes, the start_position parameter allows you to define the starting position for the search.
FIND is case-sensitive, whereas SEARCH is case-insensitive.