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
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to search; null gives null. |
substring | text | The piece to look for. |
comparer | nullable 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"))
| Order | Shop |
|---|---|
| 1001 | Oslo Central |
| 1003 | Oslo Airport |
Related functions
Text.StartsWith, Text.EndsWith, Text.PositionOf, Comparer.OrdinalIgnoreCase.