【发布时间】:2020-08-09 20:09:03
【问题描述】:
在 Excel Power Query 中,我尝试使用 List.Accumulate 添加多个自定义列,并希望使用 currentvalue 中的值填充每一列。
这是我的示例代码:
let
Query1 = let
Source = Excel.CurrentWorkbook(),
#"Expanded Content" = Table.ExpandTableColumn(Source, "Content", {"Region", "Industry", "Product type", "Series", "2000", "2001", "2002", "2003", "2004", "2005"}, {"Region", "Industry", "Product type", "Series", "2000", "2001", "2002", "2003", "2004", "2005"})
in
#"Expanded Content",
#"Changed Type" = Table.TransformColumnTypes(Query1,{{"2000", type number}, {"2001", type number}, {"2002", type number}, {"2003", type number}, {"2004", type number}, {"2005", type number}}),
#"Added Custom" = List.Accumulate({2000..2005}, #"Changed Type", (state, current) => Table.AddColumn(state, "P_" & Number.ToText(current), each [current]))
in
#"Added Custom"
一切正常,我得到了 6 个名为 P_2000、P_2001 等的新列。 例如,我想用“旧列”中的相应数据填充每个新列。因此,在“P_2000”列中,我希望与现有“2000”列中的数字相同。
each [current] 出现错误,因为它无法识别列名。有什么解决方法吗?我试图将“当前”值转换为文本,但这对我也不起作用。
欢迎任何想法!
【问题讨论】:
标签: excel powerquery