Excel - table 中的数组公式

Excel - array formula in a table

我有一个 Excel sheet,其中包含来自 power 查询的数据,这些数据已加载到 sheet。它们会自动加载为 table(不是简单范围)。

在那 table 中,我有一个姓名列表(很多重复)和一个日期。我想创建另一个列来显示每个名称的最新日期(见下图)。

我可以使用数组函数 ={MAX(IF....} 轻松做到这一点,但是 Excel 不允许在 table 中使用数组。我无法转换它范围,因为那样它就不会正确更新。

有没有办法在工作中做到这一点sheet?如果没有,有没有办法在 Power Query 中做到这一点?

更新:

当我尝试使用数组公式时出现以下错误(当然使用 CTRL + SHIFT + ENTER 提交公式)。

这是一个纯 PowerQuery 解决方案。可能会更快,更干净。

给定这个首发 table:

input table

将其命名为 "input",然后导入到查询编辑器。转到高级编辑器并粘贴此代码:

let

//Bring in the source table and adjust the type
    Source = Excel.CurrentWorkbook(){[Name="input"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Date", type date}}),

//Group on name, keeping all the rows
    Group = Table.Group(Type, {"Name"}, {{"Date", each _, type table}, {"Latest Date", each List.Max([Date]), type date}}),

//Expand the nested table and assign type
    Expand = Table.ExpandTableColumn(Group, "Date", {"Date"}, {"Date"}),
    Type2 = Table.TransformColumnTypes(Expand,{{"Date", type date}})

in
    Type2

要获得仅显示名称和最新日期的返回 table,这里是缩短的代码。希望对您有所帮助。杰克

let

//Bring in the source table and adjust the type
    Source = Excel.CurrentWorkbook(){[Name="input"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Date", type date}}),

//Group on name
    Group = Table.Group(Type, {"Name"}, {{"Latest Date", each List.Max([Date]), type date}})
in
    Group