When building a database web app, there's a good chance you may need to calculate something. To do this, we will be using a basic formula field.
With basic formulas, you can add, subtract, multiply or divide any number value. Our use case will be adding a discount to an original price.
To do this we will need:
- The original cost of the item
- The discount
- The final price
Next, we need our "Final Price" so let's add that by clicking on the basic formula field.
Because we already have our Original Cost and Discount added, we can use them within our formula by clicking on add field.
Now all we need to do is create the formula! Since we want to calculate what the final price would be given a specific discount, we will input the following:
Original Cost - ( Discount * Original Cost )
And that's all! As you can see below, when we added records with the original cost and discount, the final price was calculated: