Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi
Does anyone have a bit of code that allows me to do something like this
if select table column header contains text "date" changed type "date".
Would be handy to stick this on the end of some of my queries rather than having to go through and select.
Regards
Solved! Go to Solution.
Think @Anonymous might mean something like this instead.
let
[...],
previousStepName = [...],
dateCols = List.Select(Table.ColumnNames(previousStepName), each Text.Contains(Text.Lower(_), "date")),
transformationsList = List.Transform(dateCols, each {_, type date}),
autoDateType = Table.TransformColumnTypes(previousStepName, transformationsList)
in
autoDateType
Or in one step:
autoDateType =
Table.TransformColumnTypes(
previousStepName,
List.Transform(
List.Select(
Table.ColumnNames(previousStepName),
each Text.Contains(Text.Lower(_), "date")
),
each {_, type date}
)
)
Hi @Anonymous ,
I'm assuming you mean you want to be able to automatically perform functions on certain columns if they exist in the table.
Try this:
autoChangeTypes =
if List.Contains(Table.ColumnNames(previousStepName), "columnToFindName")
then Table.TransformColumnTypes(previousStepName,{{"columnToFindName", type text}})
else previousStepName
Pete
Proud to be a Datanaut!
Think @Anonymous might mean something like this instead.
let
[...],
previousStepName = [...],
dateCols = List.Select(Table.ColumnNames(previousStepName), each Text.Contains(Text.Lower(_), "date")),
transformationsList = List.Transform(dateCols, each {_, type date}),
autoDateType = Table.TransformColumnTypes(previousStepName, transformationsList)
in
autoDateType
Or in one step:
autoDateType =
Table.TransformColumnTypes(
previousStepName,
List.Transform(
List.Select(
Table.ColumnNames(previousStepName),
each Text.Contains(Text.Lower(_), "date")
),
each {_, type date}
)
)
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.