更新时间:2023-10-23 18:39:40
实际上你们已经很接近了.您唯一缺少的是,在您的 List.Transform
中,您希望第二个元素是一个函数,而不是列名中提取的数字.要解决这个问题,只需添加一个 each
以便它告诉如何转换每个值,而不是该值是什么.
You're actually very close. The only bit you are missing is that in your List.Transform
you want the second element to be a function, not the extracted numbers in your column name. To fix this, just add an each
so it's telling how to transform each value rather than what that value is.
(Tbl_InputTable as table, Lst_Column as list) as table => let
Result = Table.TransformColumns(
Tbl_InputTable,
List.Transform(
Lst_Column,
each {_, each Text.TrimStart(Text.Select(_, {"0".."9"}), "0")}
)
)
in
Result
定义此函数后,您应该可以像这样调用它:
With this function defined, you should be able to call it like this:
CleanRN(PrevQueryTable, {"NumericTextColumn"})
每个 ...
是一个函数,它把 _
转换成你指定的任何东西(相当于语法 (_) => ...
,一个带有参数 (_) => ...
的函数)代码>_代码>).在这种情况下,我们在一个函数中有一个函数.外层是将每个 _
转换为列表 {_, function}
,而内层是指定该函数是什么.我们想要这个列表的原因从 我之前回答过的你链接的问题.
each ...
is a function that transforms _
into whatever you specify (equivalent to syntax (_) => ...
, a function with parameter _
). In this case, we have a function within a function. The outer one is transforming each _
into a list {_, function}
and the inner one is specifying what that function is. The reason we want this list is more clear from the question you linked that I answered previously.