Forum Discussion
andres_montanag
3 years agoFrequent Visitor
pass a column name as variable
Hi guys, I need your knowledge 😄 I am trying to pass the name of a column as a variable to create a table from a custom function. this M code work: (tabla as table, fecha as date, name as ...
- 3 years ago
Hi, I found the solution in this post.
My code is as follows:
(tabla as table,nameColumn as text, fecha as date, name as text) => let Origen = tabla, #"Filtro" = Table.SelectRows(Origen, each ( Record.Field(_,nameColumn) = name) and ( [Created Date] = fecha)) in #"Filtro"the solution is the function:
Record.Field(record as record, field as text) as any
andres_montanag
3 years agoFrequent Visitor
Hi, I found the solution in this post.
My code is as follows:
(tabla as table,nameColumn as text, fecha as date, name as text) =>
let
Origen = tabla,
#"Filtro" = Table.SelectRows(Origen, each ( Record.Field(_,nameColumn) = name) and ( [Created Date] = fecha))
in
#"Filtro"
the solution is the function:
Record.Field(record as record, field as text) as any
- AlexisOlson3 years agoSuper User
Yep. And the function Table.Column is table equivalent of Record.Field (it returns a list rather than a single value).