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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply

Use a field name as a parameter

I want to have a dynamic function that uses many names as a field name.

 

GetRowData = (table, RowIter, ColumnName) =>
    let

        end = table{RowIter}[ColumnName] //This line searches for "ColumnName" as a field name. How do I make this dynamic and use the parameter?
    in
        end;

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This works:

 

(tableName as table, RowIter as number, columnName as text) =>

let

end = Record.Field(tableName{RowIter}, columnName)

in

end

 

"table' is a protected word, so you can't use that as a parameter name.  Anyway, this will result in the single value of whatever is in that field (as opposed to returning a record or a table or a list value).

 

--Nate

 

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @JackSoderstrom 

 

@Anonymous 's solution should work. Have you tried that? If it's not what you want, can you clarify more about your requirement?

 

Best Regards,
Community Support Team _ Jing

Anonymous
Not applicable

Or I guess you said you need the field name:

 

(tableName as table, RowIter as number, columnName as text) =>

let

end = List.Select(Record.FieldNames(tableName{RowIter}), each _ = columnName)

in

end{0}

 

Doing it this way though, you are probably add MissingField.Ignore somewhere in there, in case your fields aren't avaliable.

 

--Nate

Anonymous
Not applicable

This works:

 

(tableName as table, RowIter as number, columnName as text) =>

let

end = Record.Field(tableName{RowIter}, columnName)

in

end

 

"table' is a protected word, so you can't use that as a parameter name.  Anyway, this will result in the single value of whatever is in that field (as opposed to returning a record or a table or a list value).

 

--Nate

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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 Solution Authors