Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
code written by Hans Peter Pfister, www.powerbi-pro.com
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddJNCoMwEIbhu7g2JTMZ/5btBXoAceHClkIJxfsvGjQxsfMVBIWH+OZvHCtLl/Cwpb6qq+vnsbzDu7HVVP/YbfazX3z4Iov4te7qkN7X2T835sQCusZpy13DHeDUlV5jzhrinTuUZasxdzuAqWq40ZqzRJuSBVVhbTnKAjRVwchiqRKjDi5VW47Gcz/rsVQRrTnr9m2iFlVFW3GubgB8ZHuNRTX+eQDVNKMBV6UFnKrxupyw2GK3X1Tm/9mTFVkaAKcsGFoebBg6fQE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Product = _t, Amount = _t]),
#"Replaced Value" = Table.ReplaceValue(Source,"Apfel","Apple",Replacer.ReplaceText,{"Product"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","Orangen","Oranges",Replacer.ReplaceText,{"Product"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Bananen","Bananas",Replacer.ReplaceText,{"Product"}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","Birnen","Pears",Replacer.ReplaceText,{"Product"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value3",{{"Date", type date}, {"Product", type text}, {"Amount", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Total", each List.Sum(List.Range(#"Added Index"[Amount],0,[Index]))),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Total", Int64.Type}})
in
#"Changed Type1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment