Ser*_*mov 6 function powerquery
亲爱的巫师)
我正在尝试创建一个可以使用输入的搜索功能: 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
Run Code Online (Sandbox Code Playgroud)
但它导致错误:
Expression.Error:未找到表的“mColName”列。详细信息:mColName
有什么建议吗?提前谢谢了
Ald*_*ert 11
我有同样的需求,但 Table.Columns(Source,mColName) 不起作用,因为它正在返回一个列表。在我的问题中,我需要过滤作为表返回的列。
我解决了它如下:
( mTbl as table, mColName as text, mColValue as text) =>
let
Source = mTbl,
Result = Table.SelectRows(Source, each (Record.Field(_, mColName) = mColValue ))
in
Result
Run Code Online (Sandbox Code Playgroud)
[mColName] 之类的字段引用永远不会是动态的,因此代码将尝试使用名称为“mColName”的字段;它不会被参数 mColName 中的字符串替换。
相反,您可以使用: Table.Column(Source,mColName)
| 归档时间: |
|
| 查看次数: |
6467 次 |
| 最近记录: |