# How do subtract value in two consecutive rows and print it in a column

I have a situation that needs to be handled. I have values in a column that are values of that particular instance in time I need the difference between each instant.

Input and output will be something like this

``````12760  12760 (Subtract with 0)
15464  2704 (15464 - 12760)
17162  1698
19808  2646
22757  2949
25450  2693
``````

How would I achieve this with SpreadSheet? Is it even possible?

• – Rubén Nov 11 '16 at 13:13

It's not entirely clear what you're after, but I think I have the idea.

You have this data:

``````   |   A    |   B
----------------------------------------------------
1 | 12760
2 | 15464
3 | 17162
4 | 19808
5 | 22757
6 | 25450
``````

And you want column B to show the difference between the value in column A and the value in column A in the row above. That's really quite simple.

In B2 put the formula:

``````=A2-A1
``````

Then you can autofill that down the rest of column B as far as you need.

For the first row, since there's an implied zero, just put in B1

``````=A1
``````

In the end, you'll have:

``````   |   A    |   B
----------------------------------------------------
1 | 12760  |  12760
2 | 15464  |  2704
3 | 17162  |  1698
4 | 19808  |  2646
5 | 22757  |  2949
6 | 25450  |  2693
``````

(If this isn't what you're after, then please edit your question to provide further clarity.)

If your data starts in Row1 you have a special case that can be handled with a formula such as:

``````=iferror(A6-A5,A6)
``````

in B6 (assuming that is row with the last entry of interest) and then copied upwards to B1.