Power Query列名称作为参数 [英] Power Query column name as parameter
问题描述
亲爱的向导)
我正在尝试创建一个可以使用输入的搜索功能:1.搜索表2.此表中将在其中运行搜索的列3.在2
I'm trying to create a search function where I could use input: 1. Table for search 2. Column of this Table in which search will run 3. Value to search in the column specified in 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:找不到表的列'mColName'.细节:mColName
Expression.Error: The column 'mColName' of the table wasn't found. Details: mColName
有什么建议吗?提前非常感谢
Could there be any suggestions? Many thanks in advance
推荐答案
我也有相同的需求,但是Table.Columns(Source,mColName)不能正常工作,因为它正在返回列表.在我的问题中,我需要过滤作为表返回的列.
I had the same need but Table.Columns(Source,mColName) was not working because this is returning a list. In my problem I needed a filtering of the column returned as table.
我解决了以下问题:
( mTbl as table, mColName as text, mColValue as text) =>
let
Source = mTbl,
Result = Table.SelectRows(Source, each (Record.Field(_, mColName) = mColValue ))
in
Result
这篇关于Power Query列名称作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!