Forum Discussion
SaaM
5 years agoHelper II
Equivalent DAX Formula in Power query ?
Hi all, I am trying to convert a DAX formula in Power Query and so far I have not find the solution My DAX formula is : Column = IF(
ISBLANK(
MINX(
Filter(
Table,
and(
Tabl...
- 5 years ago
Hi,
It can be done like this:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMDA1UNJRMlSK1UHiGqFyzVG5FqhcQwME3xDIN0XloksbGqLx0dQboRsH5McCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Column = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", Int64.Type}, {"Column", Int64.Type}}), fnPrevMaxInLine = (tbl as table, item as number, val as number) => let FilterTbl = Table.SelectRows(tbl, each ([Item] = item and [Column] < val)), MaxCol = List.Max(FilterTbl[Column]) in MaxCol, #"Added Custom" = Table.AddColumn(#"Changed Type", "PrevMax", each fnPrevMaxInLine(#"Changed Type", [Item], [Column])) in #"Added Custom"Hope it helps.
Kind regards, Steve.
stevedep
5 years agoMemorable Member
Hi,
It can be done like this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMDA1UNJRMlSK1UHiGqFyzVG5FqhcQwME3xDIN0XloksbGqLx0dQboRsH5McCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Column = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", Int64.Type}, {"Column", Int64.Type}}),
fnPrevMaxInLine = (tbl as table, item as number, val as number) => let
FilterTbl = Table.SelectRows(tbl, each ([Item] = item and [Column] < val)),
MaxCol = List.Max(FilterTbl[Column])
in MaxCol,
#"Added Custom" = Table.AddColumn(#"Changed Type", "PrevMax", each fnPrevMaxInLine(#"Changed Type", [Item], [Column]))
in
#"Added Custom"
Hope it helps.
Kind regards, Steve.