M/Power Query 中是否有与 EARLIER 等价的对象?
比如说,我有一个表格,在 DATE 列中有很多不同的日期,在 LETTER 列中有少量字母。我现在想要每个字母的最大日期。
在 DAX 中,我会使用类似 CALCULATE(MAX([Date]),FILTER(ALL(Table),[Letter]=EARLIER([Letter])) 的方法。
我如何在 M 中实现相同的目标?
谢谢
最佳答案
2 下面代码中的解决方案。请注意,每个都使用“PreviousStep”作为基础,因此这些是单独的解决方案。
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
PreviousStep = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Letter", type text}}),
// 1. Add a column to the original table with the MaxDate for each letter
// "earlier" is just the name of a function parameter; it could as well have been "x" or "MarcelBeug"
AddedMaxDate = Table.AddColumn(PreviousStep, "MaxDate", (earlier) => List.Max(Table.SelectRows(PreviousStep, each [Letter] = earlier[Letter])[Date])),
// 2. Group by letter and get the MaxDate for each letter
GroupedOnLetter = Table.Group(PreviousStep, {"Letter"}, {{"MaxDate", each List.Max([Date]), type date}})
in
GroupedOnLetter
关于Power Query 中的 DAX EARLIER() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43069995/