Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
8 | |
8 | |
7 |
User | Count |
---|---|
17 | |
13 | |
7 | |
6 | |
6 |