I am using Power Query in Excel for Microsoft 365.
In Excel, I have created a Power Query where one of the applied steps is to filter out rows where column Description contains as a substring any of a set strings. The strings to filter out are listed in a separate worksheet named Exclude. For example:
| String to Exclude |
|---|
| Purple |
| Crimson |
| Cyan |
The table to be filtered (in worksheet Input) is as follows:
| Object ID | Owner | Description |
|---|---|---|
| 1 | Frank | Yellow legal paper |
| 2 | Sally | 4x Cyan sheets |
| 3 | Bob | Horseshoes |
The desired result (in worksheet Output) is:
| Object ID | Owner | Description |
|---|---|---|
| 1 | Frank | Yellow legal paper |
| 3 | Bob | Horseshoes |
If I were to hardcode the applied step that does the filtering, it would have the following M Language code:
let
Source = ... ,
...
#"Removed Duplicate Rows" = ... ,
#"Removed Parts to Exclude" = Table.SelectRows(#"Removed Duplicate Rows", each not Text.Contains([Description], "Purple") and not Text.Contains([Description], "Crimson") and not Text.Contains([Description], "Cyan")),
in
#"Removed Parts to Exclude"
However, end users need to be able to define the exclusion strings to use to filter rows out. This is the source of my desire to list these strings in a worksheet dedicated to that purpose instead of hardcoding them into the Power Query.
How may I accomplish this?
