Ask Your Question
1

Can column names and their contents be used as wildcards to search for strings in other columns in Powerquery?

asked 2023-07-09 07:21:33 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-09 07:49:01 +0000

lalupa gravatar image

Yes, column names and their contents can be used as wildcards to search for strings in other columns in Power Query.

To use this feature, you can create a custom function that takes the column name and the search string as inputs, and then dynamically generate a filter expression that targets the specified column.

For example, the following code searches for all rows where the "Product" column contains the string "apple", using the "Product" column name as a wildcard:

let Source = Excel.CurrentWorkbook(){[Name="SalesData"]}[Content], SearchString = "apple", FilterExpression = "= Text.Contains([" & Product & "], """ & SearchString & """)", FilteredRows = Table.SelectRows(Source, each Expression.Evaluate(FilterExpression, #table({Product}, {{[Product]}}))) in FilteredRows

Note that this code assumes that the data is stored in an Excel table named "SalesData", and that the "Product" column exists in this table. You'll need to adjust the code accordingly for your specific data source and column names.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-09 07:21:33 +0000

Seen: 15 times

Last updated: Jul 09 '23