<!-- https://learnsql.cpetoday.com/functions/m/text-contains -->
# Text.Contains

Language: Power Query M
Category: Text
Syntax: Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical
Summary: Tests whether a text value contains a given piece of text.
Returns: true or false, or null when the input is null.
Level: Beginner
Related: Text.StartsWith, Text.EndsWith, Text.PositionOf, Comparer.OrdinalIgnoreCase, Text.Lower

## What it does
Text.Contains answers the question "does this description include this word?" It is how a team flags transactions for review by keyword, such as every line that mentions "bonus" or "accrual". The test is case sensitive by default, so "Accrual" and "accrual" are different. Pass Comparer.OrdinalIgnoreCase as the third argument to ignore case.
## Syntax and arguments
- text: the value to search.
- substring: the text to look for.
- comparer (optional): how to compare. Comparer.OrdinalIgnoreCase ignores case. Leave it out for an exact, case sensitive test.
## Example
A controller wants every journal line whose description mentions an accrual, whatever the capitals. The third argument makes the search ignore case.

```powerquery
let
    Lines = #table(type table [Description = text],
        {{"Accrual reversal Q3"}, {"accrual for legal fees"}, {"Payroll tax"}}),
    Flagged = Table.AddColumn(Lines, "IsAccrual",
        each Text.Contains([Description], "accrual", Comparer.OrdinalIgnoreCase), type logical)
in
    Flagged
```

The first two rows are flagged true and the payroll row is false. Without Comparer.OrdinalIgnoreCase, "Accrual reversal Q3" would be missed because of its capital A.
## Example: a second, different use
Flag bank memos that mention a returned payment, using a short list of keywords combined with Text.Contains inside a custom column.
## Things to watch
- The default test is case sensitive. Always decide whether capitals matter, and say so in a comment.
- It finds text anywhere in the value, so "tax" also matches "taxable" and "syntax". Use a longer, more specific keyword when false hits are costly.
- A null input gives null, not false. A filter that keeps only true rows drops nulls too.
- The comparer must be a function value such as Comparer.OrdinalIgnoreCase, not a text word.
## In business terms
Keyword flags drive a lot of month-end review: accruals, reversals, manual journals, intercompany and one-time items. A search that ignores case catches what the team typed by hand, which is usually the messy part of the ledger.
