Text.Contains
TextReturns true if a text value contains a specified substring.
Syntax
Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The text value to search within. |
substring | text | Yes | The substring to search for. |
comparer | function | No | A comparer function (e.g., Comparer.OrdinalIgnoreCase) to control case sensitivity. |
Return Value
logical — true if the text contains the substring, false otherwise.
Remarks
Text.Contains checks whether a text value includes a given substring. By default, the comparison is case-sensitive. Pass Comparer.OrdinalIgnoreCase as the third argument for case-insensitive matching.
This function is commonly used inside Table.SelectRows to filter rows based on partial text matches.
Examples
Example 1: Filter orders by product name
Table.SelectColumns(
Table.SelectRows(Sales, each Text.Contains([Product], "Widget")),
{"OrderID", "Product", "Category"}
)Result
OrderID | Product | Category | |
|---|---|---|---|
| 1 | 1 | Widget A | Widgets |
| 2 | 3 | Widget C | Widgets |
| 3 | 5 | Widget A | Widgets |
| 4 | 8 | Widget C | Widgets |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks