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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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 Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors