# Variables

### Declaring variables

Declare a variable with the equals symbol '='.

```
discount = 10%                         | 10%
cost = $550                            | $550
cost - discount                        | $495.00  
```

A variable can be a single word, or an entire phrase.

### Global variables

To declare variables that works across all sheets, go to `Settings > Calculator > Global Variables` and add a new variable by clicking the plus button.

### Redefining variables

A variable can be redefined by giving it a new value.

The most recently defined value will be used on subsequent lines.

```
monthly rent = $1,900 // 2018      | $1,900
monthly rent = $2,150 // 2019      | $2,150                                   
monthly rent / 4 people            | $537.50
```

#### Variables can be added to and subtracted from

Use the `+=` and `-=` operators to modify the value of a variable

![](/files/T23woYPq0aIxqzN8XM6e)

## Tips for working with variables

#### Peeking at a variable's value

On Mac, peek at a variable's value by holding down the shift key, and hovering over the variable.

<figure><img src="/files/v8nfSpgSjoR2tSRn3S0e" alt="" width="158"><figcaption><p>Peeking at a variable value on Mac</p></figcaption></figure>

On iPad & iPhone, select a variable to peek at its value.

<figure><img src="/files/rouYILf7QJETc6gwVK3O" alt="" width="359"><figcaption><p>Peeking at a variable value on iPad &#x26; iPhone</p></figcaption></figure>

#### Auto-completing variable names

Instead of typing out a long variable name, you can press the **escape** key and then press **return** to quickly insert the entire variable name.

![Press escape to autocomplete long variable names](/files/-LgXbGIw24ybhnbSEBGq)

### Variable renaming

When you rename a variable, Soulver will offer to automatically update any lines that reference your variable to use the new name.

To invoke this feature, simply move the cursor to another line, after editing the name of a variable on a variable declaration line.

<div align="left"><figure><img src="/files/Uo4BVjutZqxJOrP4eZiQ" alt="" width="372"><figcaption></figcaption></figure></div>

## Things to note about variable declarations

#### Variables must be declared before use

You can't reference a variable *before* it has been declared.

This behaviour is consistent with how variables work in programming languages (but differs from Soulver 2).

#### Currency rounding does not apply to variable declaration lines

When you declare a variable in a currency, it will be displayed **without rounding** so it's unambiguous what the actual value stored in the variable is.

When used on subsequent lines, currency rounding will apply like usual.

<figure><img src="/files/UlpLRVJ8YOVqxBQ5FqpD" alt="" width="563"><figcaption><p>It's clear what the actual value of "cost per day is"</p></figcaption></figure>

#### Variable declarations can be excluded from the floating total

Use the View > Total options menu to configure whether the floating total should include or exclude variable declaration lines

<figure><img src="/files/j6aeyZ877cS5X6tbKsRg" alt="" width="563"><figcaption></figcaption></figure>


---

# 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://documentation.soulver.app/documentation/variables.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.
