Power Query - 列的总和/最大值/比较

Power Query - Sum / Max / Compare of Columns

我正在尝试将我的 Excel 函数转移到 Power Query (Office 365) 中。

这是来源:

Key X   A   Z   Y   B
Cat 15  5   10  5   10
Cat 25  10      5   20
Cat 5   15  5   20  10
Dog 5   25  10  5   5
Dog 5       20      15
Bird    20  15  5   5   5

这是我想要实现的目标。

非常感谢,

艾库特

试试下面

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
all=Table.ColumnNames(Source),
start="A",
end="Y",
start2="X",
end2="B",
ColumnsStartToEnd=List.FirstN(List.Skip(all,List.PositionOf(all,start)),List.PositionOf(all,end)-List.PositionOf(all,start)+1), // all columns start to end from ColumnNames
ColumnsStartToEnd2=List.FirstN(List.Skip(all,List.PositionOf(all,start2)),List.PositionOf(all,end2)-List.PositionOf(all,start2)+1), // all columns start2 to end2 from ColumnNames
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
totals = Table.AddColumn(#"Added Index", "Sum1", each List.Sum( Record.ToList( Table.SelectColumns(#"Added Index" ,ColumnsStartToEnd){[Index]}) )),
max=Table.AddColumn(totals,"Max1",each List.Max( Record.ToList( Table.SelectColumns(#"Added Index" ,ColumnsStartToEnd){[Index]}) )),
positionof = Table.AddColumn(max,"Max_column",each ColumnsStartToEnd{List.PositionOf(Record.ToList( Table.SelectColumns(#"Added Index" ,ColumnsStartToEnd){[Index]}),[Max1])}),
max2=Table.AddColumn(positionof ,"Max2",each List.Max( Record.ToList( Table.SelectColumns(#"Added Index" ,ColumnsStartToEnd2){[Index]}) )),
#"Added Custom" = Table.AddColumn(max2, "Compare", each if [Max1]=[Max2] then "TRUE" else "FALSE"),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in #"Removed Columns"

如果只需要最后一列,可以去掉一些中间步骤