Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
= Table.SelectColumns(Source,{"51a", "51b", "51c", "51d", "51e", "51f", "51g", "51h", "51i", "51k", "Entry Id"})
Hi all
I have the above M Step, is there a way to dynamically code this so that I pick up all column headers that contain 51 and additionally Entry Id?
Best regards
Ajay
Solved! Go to Solution.
Hi, @ajay_gajree
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may add a new step with the following m codes.
= Table.SelectColumns(
#"Changed Type",
List.Combine({
{"Entry ID"},
List.Select(
Table.ColumnNames(#"Changed Type"),
each Text.Contains(_,"51")
)
})
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @ajay_gajree
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may add a new step with the following m codes.
= Table.SelectColumns(
#"Changed Type",
List.Combine({
{"Entry ID"},
List.Select(
Table.ColumnNames(#"Changed Type"),
each Text.Contains(_,"51")
)
})
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Use Table.ColumnNames() to get the list and then remove everything from the list that doesn't match your requirements. Then use the remaining list in the Table.SelectColumns() statement.
How do you pass a list into table.selectcolumns? When I pass my list into the function it gets:
Expression.Error: We cannot convert a value of type List to type Text.
Details:
Value=[List]
Type=[Type]
Please show the relevant portion of the Power Query code.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
72 | |
67 | |
51 | |
38 | |
26 |
User | Count |
---|---|
89 | |
52 | |
45 | |
39 | |
38 |