Calculate the difference between rows
A step-by-step guide to referencing a previous row in a spreadsheet formula.
Last updated
A step-by-step guide to referencing a previous row in a spreadsheet formula.
Last updated
© Mito
In this example, we have daily stock prices for a bunch of different stocks. We want to calculate the daily change in stock price for each stock.
To follow along, download the data here.
We're going to use a spreadsheet formula to calculate the daily change in stock price. Create a new column for the formula.
To calculate the daily change in stock price, compare each row to the previous row. If they have the same stock symbol, calculate the difference in stock price. Otherwise, set the daily price change to zero.
If we write the formula in row 1 of the Daily Price Change column, then the formula should look like this:
Once the formula is applied, check out the results. Notice that the first row has a daily price change of zero because there was no previous stock price to compare.
For more information on Mito spreadsheet formulas, check out the spreadsheet formula reference.