我正在尝试向多列中的所有行添加一个或多个数字。现在,我必须按住转换选项卡标准添加中的每一列并一一输入数字。因此,增加了步骤数。
有时我有 30 列,所以我应该在查询中添加 30 个步骤,数字有时可能相同,有时可能不同。正确的做法是什么。这样做花了我很多时间,但我无法弄清楚。我怎样才能一步完成,可以吗?
另一个问题是,当我按住所有列并尝试添加标准功能变灰的数字时。你们都认为我做错了吗,有人可以建议正确的做法吗
我试过了。
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Full Name", type text}, {"1979", Int64.Type}, {"1990", Int64.Type}, {"1997", Int64.Type}, {"2007", Int64.Type}, {"2010", Int64.Type}}),
#"Added to Column" = Table.TransformColumns(#"Changed Type", {{"1979", each _ + 5, type number}}),
#"Added to Column1" = Table.TransformColumns(#"Added to Column", {{"1990", each _ + 10, type number}}),
#"Added to Column2" = Table.TransformColumns(#"Added to Column1", {{"1997", each _ + 20, type number}}),
#"Added to Column3" = Table.TransformColumns(#"Added to Column2", {{"2007", each _ + 15, type number}}),
#"Added to Column4" = Table.TransformColumns(#"Added to Column3", {{"2010", each _ + 30, type number}})
in
#"Added to Column4"
要一步完成此操作,您必须在编辑栏中输入内容。单击第一列并向其添加一个数字以获取为您生成的代码,您将得到以下结果:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Full Name", type text}, {"1979", Int64.Type}, {"1990", Int64.Type}, {"1997", Int64.Type}, {"2007", Int64.Type}, {"2010", Int64.Type}}),
#"Added to Column" = Table.TransformColumns(#"Changed Type", {{"1979", each _ + 5, type number}})
in
#"Added to Column"
公式栏中的最后一步将如下所示:
最后一个参数是一个列表列表,您可以根据需要复制并粘贴多个列表。例如
= Table.TransformColumns(#"Renamed Columns", {{"1979", each _ + 5, type number}, {"1990", each _ + 10, type number}, {"2007", each _ + 15, type number}})