电源查询列名作为参数
问题描述:
亲爱的向导)电源查询列名作为参数
我试图创建一个搜索功能,我可以用输入: 1.表搜索 2列此表中搜索将运行 3.价值在2
的函数指定的列搜索看起来是这样的:
(mTbl as table, mColName as text, mColValue as text) =>
let
Source = mTbl,
FilteredTable = Table.SelectRows(Source, each ([ mColName ] = mColValue)),
Result = List.Count(FilteredTable[ mColName ])
in
Result
但它会导致错误:
Expression.Error: The column 'mColName' of the table wasn't found. Details: mColName
请问有什么建议吗? 非常感谢提前
答
字段引用像[mColName]永远不会动态,所以代码将尝试使用名称为“mColName”的字段;它不会被参数mColName中的字符串替代。
而是,您可以使用:Table.Column(Source,mColName)
非常感谢,MarcelBeug! –