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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JimSales81
Helper I
Helper I

Custom Column Selection with Multiple Criteria

Hello,

 

I have a file i pull from that updates when a new period is finished.  instead of having to manually update my power Query to pull in the new column.  I want it to be dynamic.

 

So i want every column that has a Period Key (202401, 202212, etc.) and some others that will link to my DIM tables, like Territory, Customer, etc. 

 

I tried this to get the Period Keys and it works.  But i can't then add the othe columns i need.  

= List.Select(Table.ColumnNames(#"Promoted Headers"),each Text.StartsWith(_, "20"))

 

Would Love something like this 

 

= List.Select(Table.ColumnNames(#"Promoted Headers"),each Text.StartsWith(_, "20") AND text"Territory Code" AND "Customer Number"))

 

There has to be an easy way to add multple criteria to this M string.


Thank You!

 

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

Simply add the List of fixed names to your Selection:

 

 = List.Select(Table.ColumnNames(#"Promoted Headers"), each Text.StartsWith(_,"20")) & {"Territory","Customer","etc"}
in

 

View solution in original post

2 REPLIES 2
ronrsnfld
Super User
Super User

Simply add the List of fixed names to your Selection:

 

 = List.Select(Table.ColumnNames(#"Promoted Headers"), each Text.StartsWith(_,"20")) & {"Territory","Customer","etc"}
in

 

WanderingBI
Resolver III
Resolver III

I might be wrong but I believe relationsships only exist in the data model that is created in Excel or Power BI after you run your queries.

I also cannot find much about relationsships in the Power Query (M) documentation.

 

So I think the most efficient thing you can do is to merge the columns that you need ("Territory Code", "Customer Number") from the DIM tables (which are variables/queries in Power Query at this point) into the query where you are doing your "each if" operation in the custom column. This should not be too computing extensive and is propably faster than any custom function (i.e. loading the tables from the other queries into each row and then filtering down or something like that).

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors