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

Join 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.

Reply
WilkoVanA
Frequent Visitor

Passing a column as parameter to a function

Hi,

 

Something I have a workaround for but not happy with it is when I try to use custom function in Power BI and whant the name of the column as a parameter. In the example below:

fnParseColumn = (parTable as table, parNewColumnName as text) =>
    let
       AddParsedNameColumn = Table.AddColumn(parTable, "Name Trimmed", each if [Name To Parse] = null then "" else fnParseName([Name To Parse]), type text),
        RemoveOldColumn = Table.RenameColumns(Table.RemoveColumns(AddParsedNameColumn, {"Name To Parse"}),{{"Name Trimmed", parNewColumnName}})
    in
        RemoveOldColumn,

 

There is a column in the table (called "Name To Parse") in the original table that is created by renaming a column to ensure the function to pick the right one. How can I pass the name of that column as a parameter and then (more importantly) how can I use it in the statements above?

 

Any help is greatly appreciated.

Wilko

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Why not just pass the entire column in versus the name using something like Table.SelectColumns? Or I may be missing something.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for the suggestion. I tried that but didn't succeed in getting the syntax right. What is the type that is passed to the function? How do I refer to it in the function?

 

If you have some hints or code snippets as examples....

 

Regards,

Wilko

WilkoVanA
Frequent Visitor

Hi,

 

Something I have a workaround for but not happy with it is when I try to use custom function in Power BI and whant the name of the column as a parameter. In the example below:

fnParseColumn = (parTable as table, parNewColumnName as text) =>
    let
       AddParsedNameColumn = Table.AddColumn(parTable, "Name Trimmed", each if [Name To Parse] = null then "" else fnParseName([Name To Parse]), type text),
        RemoveOldColumn = Table.RenameColumns(Table.RemoveColumns(AddParsedNameColumn, {"Name To Parse"}),{{"Name Trimmed", parNewColumnName}})
    in
        RemoveOldColumn,

 

There is a column in the table (called "Name To Parse") in the original table that is created by renaming a column to ensure the function to pick the right one. How can I pass the name of that column as a parameter and then (more importantly) how can I use it in the statements above?

 

Any help is greatly appreciated.

Wilko

Helpful resources

Announcements
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