如果要查找硬编码列 A/Z/Y 的最大值,请添加索引并使用代码
#"Add Max"=Table.AddColumn(#"Added Index" ,"Max",each List.Max( Record.ToList( Table.SelectColumns(#"Added Index" ,{"A","Z","Y"}){[Index]}) )),
如果您已经有一个名为Max的最大列,并且您想在硬编码的列名称 X/A/Z/Y/B 中找到它来自哪个列,则使用代码
#"Add Label"=Table.AddColumn(#"PriorStepName","MaxLabel",each {"X","A","Z","Y","B"}{List.PositionOf(Record.ToList( Table.SelectColumns(#"PriorStepName",{"X","A","Z","Y","B"}){[Index]}),[Max])})
两者都做:
let Source = Excel.CurrentWorkbook(){[Name="Table14"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", type text}, {"X", Int64.Type}, {"A", Int64.Type}, {"Z", Int64.Type}, {"Y", Int64.Type}, {"B", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Add Max"=Table.AddColumn(#"Added Index" ,"Max",each List.Max( Record.ToList( Table.SelectColumns(#"Added Index" ,{"A","Z","Y"}){[Index]}) )),
#"Add Label"=Table.AddColumn(#"Add Max","MaxLabel",each {"X","A","Z","Y","B"}{List.PositionOf(Record.ToList( Table.SelectColumns(#"Add Max",{"X","A","Z","Y","B"}){[Index]}),[Max])})
in #"Add Label"
如果要选择列col1,col2,col3,这些名称是硬编码的,那么只需使用
#"Removed Other Columns" = Table.SelectColumns(#"priorstepname",{"col1", "col2", "col2"})
所以特别
Table1=Table.SelectColumns(#"priorstepname",{"X", "A", "Z","Y","B"}), Table2=Table.SelectColumns(#"priorstepname",{"A", "Z","Y"}),