March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I am trying to subtract two consecutive rows from each other (Power) based on a condition from another column (Day No.) to yield a new value (Power_2) as shown below. However, once a new Day No. is reached, the first value of that day will remain the same and be copied into the Power_2 column.
Thanks
Solved! Go to Solution.
Hi @Anonymous
Hope this works for you.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcqxDcAwDAPBXVirsKjYyxjaf40EQoDvrrh7lQrlUsfPhIY1NNfc4YZnWB+9YELDgo+6Xw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Day = _t, Power = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Day", Int64.Type}, {"Power", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Power_2", each let _day = [Day], _power = [Power] in [Power] - Replacer.ReplaceValue( List.Max( Table.SelectRows( #"Changed Type", each [Day] = _day and [Power] < _power )[Power]), null, 0 ), Int64.Type ) in #"Added Custom"
Hi @Anonymous
Hope this works for you.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcqxDcAwDAPBXVirsKjYyxjaf40EQoDvrrh7lQrlUsfPhIY1NNfc4YZnWB+9YELDgo+6Xw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Day = _t, Power = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Day", Int64.Type}, {"Power", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Power_2", each let _day = [Day], _power = [Power] in [Power] - Replacer.ReplaceValue( List.Max( Table.SelectRows( #"Changed Type", each [Day] = _day and [Power] < _power )[Power]), null, 0 ), Int64.Type ) in #"Added Custom"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
34 | |
30 | |
20 | |
19 | |
12 |