Forum Discussion
Substract Previous row
- 4 years ago
Hi naveen_85
You can first add an Index column which starts at 0 (this column will be used like row number in the following step). Then add a custom column with below code. "Added Index" is the previous step name. Modify it according to your transformation steps.
let previousTotal = #"Added Index"{[Index]-1}[Total Payroll], diffTotal = [Total Payroll] - previousTotal in if diffTotal > 0 then ([New Hired]-diffTotal)/[Total temporary] else [New Hired]/[Total Payroll]There is an error in the first row because it doesn't have a previous row. You can replace error value with Replace Errors feature under Transform tab > Replace Values. You can format the numbers in the custom column per your need.
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Hi naveen_85
You can first add an Index column which starts at 0 (this column will be used like row number in the following step). Then add a custom column with below code. "Added Index" is the previous step name. Modify it according to your transformation steps.
let
previousTotal = #"Added Index"{[Index]-1}[Total Payroll],
diffTotal = [Total Payroll] - previousTotal
in
if diffTotal > 0 then ([New Hired]-diffTotal)/[Total temporary] else [New Hired]/[Total Payroll]
There is an error in the first row because it doesn't have a previous row. You can replace error value with Replace Errors feature under Transform tab > Replace Values. You can format the numbers in the custom column per your need.
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.