How to apply discounts dynamically with formulas

Banner image for Baserow blog to apply discounts in Baserow with formulas

Spreadsheets can be useful for making calculations. But sometimes spreadsheets can get clunky and complex. This is where Baserow comes in.

Baserow offers the power and flexibility of a spreadsheet but goes far beyond the limitations of spreadsheets. It offers a powerful and user-friendly platform for managing your data, automating tasks, and streamlining your workflows. Imagine being able to create automatic discounts for your products or services based on specific rules you set. Baserow automates these discounts, saving you time and ensuring everyone on your team uses the same consistent pricing.

This not only simplifies applying discount but also ensures consistency and accuracy. Let’s explore some use cases:

  • Volume discounts: Reward bulk purchases with automatic price reductions.
  • Loyalty programs: Offer tiered discounts to repeat customers.
  • Promotional offers: Trigger discounts based on specific codes or campaign periods.
  • Minimum order thresholds: Incentivize higher-value purchases with automatic discounts.

With these use cases in mind, let’s unlock the power of automated discounts in Baserow!

What we’ll do

In this tutorial, we’ll dive into how to leverage Baserow formulas to set up a system that automatically applies discounts to products or services based on certain conditions. We’ll cover the following steps:

Prerequisites

To complete this tutorial, you’ll need the following:

Let’s dive in!

Automate discount calculation using formulas

In this tutorial, we’ll cover how to automatically give customers a special offer if they order a certain amount, or reward loyal buyers with a percentage off. However, you can apply the same principles to other use cases.

1. Set up your Baserow database

If you already have a Baserow account, log in. Otherwise, create a new account.

Once logged in, you’ll see your workspaces. You can work with an existing workspace, database, or table, or set up a new workspace from scratch.

We’ll start by creating a new workspace. Just click the + Create workspace button and follow the steps. If you’re new to Baserow, there are helpful articles linked that explain workspaces and collaboration in more detail.

With your workspace ready, you can now add a database. Click the + Create new button and choose “Database” to build one from scratch. You can name it something like “Discount management”. Alternatively, you can explore our template library for pre-made options.

A default table will already be there for you to start adding and organizing your data. Let’s name it “Products”. This table will store information about the products or services you’re offering.

2. Add fields to the table

Let’s add the following fields to the Products table:

  • Product name: Single line text
  • Original price: Number
  • Discount percentage: Number
  • Discounted price: Formula

Now, we can populate the Products table with sample data. Here’s an example of what the table might look like:

Product name Original price ($) Discount percentage (%) Discounted price ($)
Product A 100 10
Product B 150 20
Product C 200 15

3. Create the discount formula

To dynamically calculate the discounted price, we’ll use a formula in the Discounted price field.

  1. Select the Discounted price field: Click on the Discounted price column header and select Edit field.

  2. Choose formula: In the field type options, choose “Formula”.

  3. Enter the formula: Use the following formula to calculate the discounted price:

    field('Original price ($)') * (1 - field('Discount percentage (%)')/ 100)
    

    This formula calculates the final price of an item after applying a discount. Here’s a breakdown:

    • field('Original price ($)') represents the original price of the item before the discount.
    • field('Discount percentage (%)') represents the discount percentage as a number (for example, 10 for a 10% discount).
    • The entire expression (1 - field('Discount percentage (%)')/ 100) calculates the discount amount as a proportion of the original price (1 minus the discount percentage divided by 100).
    • Multiplying the original price by this discount proportion gives you the final price after applying the discount.
  4. Save the formula: Click “Save”. The table should now automatically calculate the discounted price based on the original price and the discount percentage.

Create the discount formula

You can enter sample data into your table to verify that the discounts are being applied correctly.

Now, let’s automatically apply discounts to these products or services based on specific rules.

4. Add conditional discounts

Let’s say we want to apply discounts conditionally based on certain criteria, such as a minimum purchase amount or a specific product category. Here’s how we can do that:

  1. Add a new field for condition: Add a new field named “Apply discount” with the boolean field type. This field will determine if the discount should be applied.
  2. Modify the discount formula: Update the “Discounted price” formula to include the condition. The new formula will look like this:
if(field('Apply discount'), field('Original price ($)') * (1 - field('Discount percentage (%)')/ 100), field('Original price ($)'))

This formula checks if a discount needs to be applied. If yes (represented by “Apply discount” being true), it calculates the discounted price by multiplying the original price by the percentage remaining after subtracting the discount percentage (as a decimal) from 1. Otherwise, it simply shows the original price.

Add conditional discounts

5. Add advanced discount conditions

For more complex conditions, such as applying discounts based on purchase amounts or dates, you can use additional fields and more sophisticated formulas. Here’s an example of a formula that applies a discount only if the original price is over $200:

if(field('Original price ($)') > 200, field('Original price ($)') * (1 - field('Discount percentage (%)')/ 100), field('Original price ($)'))

Setting up these rules in Baserow frees you from manual calculations and ensures everyone gets the correct price. To save even more time, consider setting up automatic updates and notifications.

Finally, make sure the formula works correctly by checking for any errors. If the discounts are not calculating as expected, double-check your formulas and ensure all fields are correctly formatted. If needed, adjust the formula to fix any problems.

Summary

Baserow goes beyond just organizing data. With these formulas, you can create automatic discounts in Baserow, taking the manual work out of pricing and saving you valuable time.

Automating discounts saves you time and ensures consistent pricing. Imagine offering a 10% discount for bulk orders or a loyalty program discount for repeat customers. This lets you easily set up different discount rules based on your needs, whether it’s giving a percentage off for high-volume orders or offering a flat discount for specific customers. This can lead to happier customers and increased sales.

Other useful resources

The following articles may also be helpful:

In case you’ve run into an issue while following this tutorial, feel free to reach out to ask for help in the Baserow community.