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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DanFromMontreal
Helper IV
Helper IV

Passing table field name as a parameter to a function in PowerM

Hello all, I'm struggling to pass a table field name as a parameter to a function.

I've tried several things but none worked.... this 

DesiredField is the column in the table "tblFolder" I want to return a value from.

I'm sure it is simple but since I'm a novice....

 

//fxFieldContent
(Year as number, DesiredField as text) =>
let
  aaa = DesiredField,
  Source = tblFolder,
  #"Filtered lines" = Table.SelectRows(Source, each ([Year] = Year) and ([Selection] = "X")),

  //FieldContent = #"Filtered lines"{0}[Path]& #"Filtered lines"{0}[File] // Working but field in hardcoded
  //FieldContent = #"Filtered lines"{0}{DesiredField} doesn't work
  //FieldContent = #"Filtered lines"{0}[aaa] //doesn't work
  //FieldContent = #"Filtered lines"{0}[#"Record.Field(_,DesiredField)"] //doesn't work

  // By using [DesiredField], it is trying to find the field "DesiredField" in tblFolder, which does not exist!

  //How can I change the [DesiredField] and use the parameter "DesiredField" to select my   desired field?

 FieldContent = #"Filtered lines"{0}[DesiredField]
in
FieldContent

 

Thank you for your help.

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @DanFromMontreal  you were close 😉

 

 

Record.Field(#"Filtered lines"{0}, aaa)

or

Record.Field(#"Filtered lines"{0}, DesiredField)

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

3 REPLIES 3
DanFromMontreal
Helper IV
Helper IV

Thank you so much dufoq3

You're welcome 😉


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

dufoq3
Super User
Super User

Hi @DanFromMontreal  you were close 😉

 

 

Record.Field(#"Filtered lines"{0}, aaa)

or

Record.Field(#"Filtered lines"{0}, DesiredField)

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.