Power Query — List functions to help you

Peter Hui
CodeX
Published in
3 min readJan 21, 2023

--

…select columns with multiple criteria's

Photo by Austin Chan on Unsplash

Power Query is a powerful tool in Microsoft Excel and Power BI that allows users to shape and transform their data before using it for analysis and visualization. One of its key features is the ability to select columns based on certain criteria.

Sometimes, selecting columns can be easy and can be done by using the drop-down menu. However, other times, you may have hundreds of columns that need to be selected based on certain criteria, and it can be hard to select them all individually. In such cases, you can functions to select the columns based on your criteria.

List.Select with Text.Contains to select column headers

Here is an example of a function that can be used to select columns based on certain criteria in Power Query:

List.Select(Table.ColumnNames(#”Removed Columns”), each Text.Contains(,”ology”) or Text.Contains(,”prep_”))

This function works by taking the previous power query step, #“Removed Columns” — which returns a table and using the Table.ColumnNames function to return a list of names that belong to the table. The List.Select function then selects only the items in the list that match the specified criteria, which in this case are the list that contains…

--

--

Peter Hui
CodeX

I write about Power BI, Power Automate and other cool Microsoft power tools. Microsoft certified data analyst. Constant learner and an aspiring writer. 👍