Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Im traing to calculate the price variation between two dates.
Is just a rest but i dont know how to do it.
Thank you
Solved! Go to Solution.
Hi @Anonymous,
Assuming that the data is ordered by date:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdHLDcQwCATQXnyOCGDzcS1W+m9jV7CRYK9PyMzgcwbdSDcj87jGVlAez3UGV53gEjqrMqwduqoKoIVKn3UK1aobdIZaVQJaoV4VwTLD7rOSs4S9hmcNop6C8w3iHmNp8uxN3kdWD+K/ldJXcjYk7aezPAfZ3+082TvvPAi1lvZOM/bc8v2A5wM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Brent = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Brent", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Var", each 0, type number),
ToList = Table.ToRecords(#"Added Custom"),
Calculate = List.Accumulate(List.Skip(ToList), {List.First(ToList)}, (a,n)=> a & {Record.TransformFields(n,{"Var", (x)=> n[Brent] - List.Last(a)[Brent]})}),
Output = Table.FromRecords(Calculate, Value.Type(#"Added Custom"))
in
Output
Kind regards,
John
Thank you! Helpful 😁
Hi @Anonymous,
Assuming that the data is ordered by date:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdHLDcQwCATQXnyOCGDzcS1W+m9jV7CRYK9PyMzgcwbdSDcj87jGVlAez3UGV53gEjqrMqwduqoKoIVKn3UK1aobdIZaVQJaoV4VwTLD7rOSs4S9hmcNop6C8w3iHmNp8uxN3kdWD+K/ldJXcjYk7aezPAfZ3+082TvvPAi1lvZOM/bc8v2A5wM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Brent = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Brent", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Var", each 0, type number),
ToList = Table.ToRecords(#"Added Custom"),
Calculate = List.Accumulate(List.Skip(ToList), {List.First(ToList)}, (a,n)=> a & {Record.TransformFields(n,{"Var", (x)=> n[Brent] - List.Last(a)[Brent]})}),
Output = Table.FromRecords(Calculate, Value.Type(#"Added Custom"))
in
Output
Kind regards,
John
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 16 | |
| 12 | |
| 9 | |
| 7 | |
| 6 |