OpenBI Docs Buy

Text.Contains

Whether a text has a piece of text anywhere in it.

Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical
ParameterTypeDescription
textnullable textThe text to search; null gives null.
substringtextThe piece to look for.
comparernullable function
optional
How to compare: Comparer.Ordinal (the default, case counts) or Comparer.OrdinalIgnoreCase.

Returns

nullable logical. true when the piece is found; null when the text is null.

Examples

Case counts

Text.Contains("Oslo Central", "central")
false

Ignoring case

Text.Contains("Oslo Central", "central", Comparer.OrdinalIgnoreCase)
true

Keep the orders of one shop

let
    Orders = #table({"Order", "Shop"}, {{1001, "Oslo Central"}, {1002, "Bergen"}, {1003, "Oslo Airport"}})
in
    Table.SelectRows(Orders, each Text.Contains([Shop], "Oslo"))
OrderShop
1001Oslo Central
1003Oslo Airport

Text.StartsWith, Text.EndsWith, Text.PositionOf, Comparer.OrdinalIgnoreCase.

Last updated · OpenBI Studio 0.3.79