# How to Perform Basic Calculations Updated by Rafaela Basso

#### Do you need to perform basic mathematical calculations on your chatbot? Find out how toeasily do this by setting variables!

Note: This Block is only available on Premium Accounts.

It is possible to perform mathematical calculations in your bot just using Set Variable blocks 🚀

### Set a Variable

In the Set Variable block, you must create or select the Variable you want to attribute a value to.

To perform calculations, you must use variables in the format of Number, so make sure you choose the right type 😅

Once you have created or chosen a Variable in the format of Number, you will see the option ‘Perform a Calculation’.

### Perform a Calculation

After selecting the Perform a Calculation option, you will notice that a new field is opened.

In this field you can perform calculations to add, subtract, multiply, divide or make percentage operations.

First, you must define the value of the Variable you will be using in the calculation.

Keep in mind that this is an initial value, that will be altered as you build the calculation in your bot 😉

To perform an addition or subtraction operation, create a new Variable or alter a preexisting one. This Variable will be the result of this calculation.

Insert a Start Value and End Value, which can also be variables.

Choose the ‘ - ’ symbol between these two values to subtract, or the ‘ + ’ symbol to add.

This is how the it will look like in your bot:

#### Multiplying or Dividing

To perform a multiplication or division operation, create a new Variable or alter a preexisting one. This Variable will be the result of this calculation.

Insert a Start Value and End Value, which can also be variables.

Choose the ‘ * ’ symbol between these two values to multiply, or the ‘ / ’ symbol to divide.

This is how the it will look like in your bot:

Final result

To show the final result on your bot, don’t forget to insert the Variable you have created/altered in a new block, like in a message or buttons block.

You can check out a demo of a bot performing these calculations on this link.

#### Percentage

Considering you already know how to perform add/subtract, multiply/divide operations, it will be easy to perform percentage operations! 🙌

Just like you learned in the previous mathematical calculations, to perform a percentage operation, you have to create a new Variable or alter a preexisting one. This Variable will be the percentage resulting of this calculation.

Insert a Start Value and End Value, which can also be variables.

(a) Deducting a Percentage

Choose the ‘ * ’ symbol between these two values, and multiply by 0.(percentage) .

For instance, if you want to find out how much is 30% off 100, you have to multiply 100 by 0.3 .

Once you found out the percentage wanted, you just have to subtract it from the Start Value

Choose the ‘ * ’ symbol between these two values, and multiply by 1.(percentage).

For instance, if you want to ad 30% to 100, you have to multiply 100 by 1.3 .

You can check out a demo of a bot performing these percentage operations through this link.

And that's it! Now you can do all the calculations you need in your chatbots 🚀

#### Bonus 😎

1. You can format the ending result, for example if you want it  to show only 2 decimals.

Check out how to do it in this link.

2. You can also perform calculations with Dates. For days, based on a variable that is a date (with Landbot format) you can sum or subtract days or month or years to that specific date.

### How did we do?

#### Set Variable 