Power Query: Filtering columns based on text content

studioacosta

New Member
Joined
Jan 17, 2025
Messages
9
Office Version
  1. 365
Platform
  1. Windows
I want to filter and keep only the columns that contain a specific project number anywhere in the data cells (not in the column name). I'm struggling to figure out how to do that - I thought a Table.SelectColumns function would work with Text.Contain but I can't get it to work. Am I on the right track? Is there a better way?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
@studioacosta, you need to feed Table.SelectColumns with a list of column names. So you start with Table.ColumnNames list and you need to select names that conform to your condition:
List.Select(Table.ColumnNames(tbl), (x) => func(Table.Column(tbl, x))) where func is function that accepts a list of values and checks for you condition. So it gives ether true or false.
 
Upvote 0
Solution
@studioacosta, you need to feed Table.SelectColumns with a list of column names. So you start with Table.ColumnNames list and you need to select names that conform to your condition:
List.Select(Table.ColumnNames(tbl), (x) => func(Table.Column(tbl, x))) where func is function that accepts a list of values and checks for you condition. So it gives ether true or false.
Thanks! Once I ended up adding a hidden row to the top of the timesheet that contained the data I needed to filter by, I was able to get what I needed.
 
Upvote 0

Forum statistics

Threads
1,226,067
Messages
6,188,700
Members
453,493
Latest member
BRACE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top