top of page

You are learning Power Query in MS Excel

How to use wildcards (* and ?) for filtering in Power Query?

Power Query itself doesn't directly support wildcards like asterisk (*) and question mark (?) for filtering. However, you can achieve similar results using different techniques:

Here are two common approaches:

1. Text.StartsWith or Text.EndsWith functions:

These functions allow you to filter based on whether a text string starts or ends with specific characters.

* Text.StartsWith(columnName, startingText): This function returns TRUE if the value in the "columnName" column starts with the provided "startingText". You can use this for filtering data like product names or addresses.

* Text.EndsWith(columnName, endingText): This function works similarly, but checks if the value ends with the specified text.

Example:

Say you have a "Product Name" column and want to filter for products starting with "Apple". You can use this formula in the filter query:

```
Table.Filter(yourTable, Text.StartsWith([Product Name], "Apple"))
```

2. List.Contains function:

If you have a list of specific text options to filter by, you can use the List.Contains function.

* List.Contains(list, value): This function checks if a specific "value" exists within the provided "list".

Example:

Imagine you have a "Color" column and want to filter for products with colors "Red", "Green", or "Blue". You can create a list of these colors and filter like this:

```
colorList = {"Red", "Green", "Blue"}
filteredTable = Table.Filter(yourTable, List.Contains(colorList, [Color]))
```

Remember to replace "yourTable" and "columnName" with your actual table and column names.

These are just a couple of ways to achieve filtering with partial text matches in Power Query. There might be other approaches depending on your specific scenario.

bottom of page