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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors