# How to write a formula for the ROI Calculator

### Let's add a Formula to your ROI Calculator.

Once you've added your **ROI calculator **to your Qwilr Page, it's time to create a formula for the calculation.

**In this article:**

- Parts of a formula
- Ranges for your variables
- Adding the formula to your calculator
- What is calculated first?

For this guide, we're assuming that you've already added the ROI Calculator to your page and set up your variables. Haven't done that yet? Check out this guide!

**Adding a Formula**

To add or edit a Formula, click on the **ROI Options** icon in your calculator. Click anywhere in the formula text field to bring up the **editing toolbar**.

### Your ROI formula can have up to 3 parts:

#### 1. Variables

Variables represent the actual numbers in your formula. (See this guide for more details on setting up variables.)

They look like a letter in two sets of curly brackets, like this: **{{A}}**. (The calculator will assign a letter to each value automatically.)

You can add a variable to your formula by clicking the **Variables** **icon** (V) and then choosing from your list of variables.

**Note: **The calculator uses these symbols instead of actual numbers to keep the calculation flexible. That way, you and your buyer can move the slider to adjust the parameters as needed and see the numbers change.

**Note:** If you're using one of the preset calculators, we recommend editing the existing variables instead of deleting them to add new ones. Deleting variables will cause the preset formula to break.

#### 2. Operators

Operators are common math functions. The ROI calculator can multiply, divide, add, and subtract.

To add an operator, click the math functions in the toolbar like this:

#### 3. Conversion calculations

This is an optional part of your formula. It will depend on the variables you're using.

Each of your variables will have a unit of measurement. Here are just a few examples:

- Per day
- Per month
- Per year
- Per lead
- Per hour

When you have variables with **different** units of measurement, you'll want to include a conversion calculation in your formula. Essentially, this converts variables to the same unit of measurement so they can be calculated accurately.

As an example, let's say you're building a formula to show the number of dollars your client will save per year. You have a variable that's "Leads per month." So you'll need to include a conversion in your formula, from the monthly value to the annual one. You can add a multiplication by 12 for that, since 12 months = 1 year.

Add the multiplication operator and type in "12." It will look something like this.

**Note: **You can type in any numbers you need for conversion calculations. You can also manually type in your variables, though using the toolbar helps prevent errors.

### Ranges for your variables

As we covered in this guide, you can set each of your variables to represent a range of values. That way you and your client can try out different values within each range.

No matter what range you set, the ROI calculator will use the current value you add for each variable.

You can change the current value or the range at any time.

**Note: **Once you share the calculator with your client, they'll only be able to change the current value – not the range.

### Adding the formula to your calculator

If you've ever used an Excel spreadsheet to make calculations, this process is very similar to that.

Clicking on **Variables** brings up a list of your variables. Choose the one you want to add to your formula.

Clicking on any of the calculation operators (+, -, x, or ÷) will add it to your formula.

You can edit your formula at any time, either using the toolbar or typing manually. You can insert variables and operators anywhere in your formula.

If the current formula can't be calculated with its existing parameters, you'll see an error message.

This error may appear as you're adjusting your formula. If you make additional changes that re-validate the formula, the error will disappear.

One common source of errors is in the order of calculation. Read on for more details.

#### What is calculated first?

The ROI calculator works with your formula in a specific order – it's called the "order of precedence."

- Anything in parentheses is calculated first
- Multiplication and division are calculated second
- Addition and subtraction are calculated third

You can see this in action in the sample formula below.

As you write your formula, keep this order in mind. If you're seeing a different calculated result than you expect, this order of precedence is often the reason.

Make sure to add parentheses around any parts of your formula that need to be handled first. Then, remember that multiplication/division will always be calculated before addition/subtraction. If you need to have any addition or subtraction happen first, put them in parentheses!

**Note:** If you do spreadsheet calculations, you might be familiar with the acronym "PEMDAS." It describes the standard order of precedence for spreadsheets. Qwilr's ROI calculator works very similarly, except that it doesn't calculate exponents. So our acronym is more like "PMDAS."

If you have questions or feedback please reach out to our Support team at [email protected].