Parameterizing a column name

ColinBurrows

New member
Joined
Feb 25, 2017
Messages
3
Reaction score
0
Points
0
Location
New Jersey, USA
Excel Version(s)
Office 365 ProPlus
I am trying to pass in a fieldname as a parameter to a function.
Within the function I need to filter a table using Table.SelectRows(table, each fieldname = something)
The problem I'm having is that no matter what I do, fieldname is always surrounded by double quotes so nothing gets returned.
Any ideas?
Thanks
 
Try

Code:
(tablename as table, fieldname as text) as table =>
let
    Result = Table.SelectRows(tablename, each Table.Column(_, fieldname) = something)
in
    Result

Remark: typically a table column would be passed to a function with type list (fieldname as list), but then you get a list with the fieldvalues, which can't be used as a reference within the Tabe.SelectRows function.
 
Many thanks. That works. Am still learning as I go and hadn't seen the Table.Column function.
Much appreciated.
 
Back
Top