 ## How do I create formula in the rule action values?

Some times you may wish to use formula's to calculate automatically a total of some kind using the variables you have selected. A common example would be for a rule charging "Per Passenger".

You can create a formula in the fields Change Mileage Total, Change Pickup Total, and Change Minutes Total.

##### How do I start a formula?

You can start a formula in the exact same way as you would do in an excel document, by starting it with an equal sign ( = )

##### What kind of formula can I make?

You can do addition using a plus sign ( + ), subtraction using a negative sign ( - ), multiplication using the star sign ( * ), and division using the forward slash sign ( / ).

##### How do I reference a variable?

You can reference a variable by using the squiggly brackets and the row number of the variable you wish to use. For example, if the first variable you've chosen in the conditions is Total Passengers, you can enter it as {1}.

If you had a second variable/row you wanted to use, you would enter it as {2}

##### How do I do a basic multiplication formula?

A good example of a multiplication formula is to calculate a \$2.00 fee per passenger, so ensure you have selected Total Passengers is greater than 0 as your first condition, and in the actions select "Change Pickup Total" and operator as + Add and in the value enter: ={1}*2.00

##### Can you provide me a JSON example of the above example?

Sure, this is found below:

#### JSON Source Code

``````{
"event": "before_booking",
"conditions": {
"0": {
"command": "passengers",
"operator": "greaterThan",
"value": "0"
},
"match": "all",
"frequency": "unlimited"
},
"actions": {
"0": {
"command": "change_pickup_fee",