Text.Contains

Text

Returns true if a text value contains a specified substring.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical

Parameters

NameTypeRequiredDescription
texttextYesThe text value to search within.
substringtextYesThe substring to search for.
comparerfunctionNoA comparer function (e.g., Comparer.OrdinalIgnoreCase) to control case sensitivity.

Return Value

logicaltrue 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
11Widget AWidgets
23Widget CWidgets
35Widget AWidgets
48Widget CWidgets

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks