# Calculate the difference between rows

#### Step 1: Import Daily Stock Prices&#x20;

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.&#x20;

To follow along, download the data here.&#x20;

{% file src="/files/T0b33EyErsEbvSwlmpIR" %}

<figure><img src="/files/zwR3N3wMvCu8elA08fJm" alt=""><figcaption><p>Import data into Mito</p></figcaption></figure>

#### Step 2: Create a new column&#x20;

We're going to use a spreadsheet formula to calculate the daily change in stock price. Create a new column for the formula.&#x20;

<figure><img src="/files/XlQy2RGE08x22DnEyrTN" alt=""><figcaption><p>Add a new column</p></figcaption></figure>

#### Step 3: Write the spreadsheet 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.&#x20;

If we write the formula in row 1 of the Daily Price Change column, then the formula should look like this:

```
IF(Symbol1==Symbol0, Close1-Close0,0)
```

<figure><img src="/files/9m8ikPAChaB16ANUZOPO" alt=""><figcaption><p>Calculate the difference between daily stock prices</p></figcaption></figure>

#### Step 4: View the results

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.

<figure><img src="/files/liVNTHyCw76uDKIsUKFc" alt=""><figcaption><p>View the results</p></figcaption></figure>

For more information on Mito spreadsheet formulas, check out the [spreadsheet formula reference](/how-to/interacting-with-your-data.md).&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.trymito.io/how-to-1/calculate-the-difference-between-rows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
