powerquery - DAX EARLIER() function in Power Query -
is there an equivalent earlier in m/power query?
say, have table lots of different dates in column date , smaller number of letters in column letter. want maximum date each letter.
in dax, use calculate(max([date]),filter(all(table),[letter]=earlier([letter])).
how achieve same in m?
thanks
2 solutions in code below. notice each uses "previousstep" basis, these separate solutions.
let source = excel.currentworkbook(){[name="table1"]}[content], previousstep = table.transformcolumntypes(source,{{"date", type date}, {"letter", type text}}), // 1. add column original table maxdate each letter // "earlier" name of function parameter; have been "x" or "marcelbeug" addedmaxdate = table.addcolumn(previousstep, "maxdate", (earlier) => list.max(table.selectrows(previousstep, each [letter] = earlier[letter])[date])), // 2. group letter , maxdate each letter groupedonletter = table.group(previousstep, {"letter"}, {{"maxdate", each list.max([date]), type date}}) in groupedonletter
Comments
Post a Comment