none
How can I do calculation based on next/prior row in Power Query? RRS feed

  • Question

  • Hi,

    Is there any possible to achieve the following statement in Power Query (Query Editor)?

    if (Id = Prior/Next row's Id) then (Quantity + Prior/Next row's Quantity)

    Thanks.

    Regards,

    Qilong

    Sunday, January 4, 2015 7:38 AM

Answers

  • You could try adding an index column, and then using the current row's index to look up the value in the prior/next rows.

    Ehren

    Wednesday, October 28, 2015 10:33 PM
    Owner
  • The code to achieve this is quite obscure.  Assuming you add an Index with the default Step name "Added Index", then on the next step you can refer to the prior row's value from column: "My Column" using:

    = #"Added Index"{[Index]-1}[My Column]

    Monday, November 2, 2015 5:28 AM

All replies