Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GlassShark1
Helper III
Helper III

Filter a list of column names by string contained in the header

I'm getting a list of column names from a table like this:

All_Columns = Table.ColumnNames(Source)

In that list of column names, i've got a few that start with "Yr " and then an appropriate number - e.g ("Yr 1", "Yr 2" and so on)

This can be any length, so could stop at "Yr 10" or "Yr 40". 

Is there a way to filter All_Columns down further a create a list of all those that start with "Yr "?

 

Struggling to find much on applying conditional arguements to a list

Thanks! 🙂

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

You can use this syntax with List.Select to keep just those column names.

 

= List.Select(Table.ColumnNames(Source), each Text.Start(_,2)="Yr")

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

You can use this syntax with List.Select to keep just those column names.

 

= List.Select(Table.ColumnNames(Source), each Text.Start(_,2)="Yr")

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Perfect! Thanks! 🙂

amitchandak
Super User
Super User

@GlassShark1 , you can unpivot and then you get that in a row and create a list from that data.

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I'm trying to automate this so that the query can find the right columns on it's own. If i pivot on the columns, i first need to select them, and this would need to be hard-coded? This is what i'm trying to avoid...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.