Setting Up a Calculated Field
Learn how to set up your own calculated fields and use them to power your loyalty or referral program's rules.
Calculated fields enable you to track events as they come in, set up a calculation using event fields, and store the resulting data on a participant’s profile. Once the calculated field is set up, its value will update dynamically as you send us events that meet your criteria.
This guide will show you the basic process for setting up a calculated field, including two examples at the end. For more details about how calculated fields work and what types of calculations are possible, see our article on calculated fields.
🔗 Setting up a calculated field
- Log on to the SaaSquatch Admin Portal.
- Go to the Data page and click the Fields tab.
- Note: You can also create a calculated field from the Program Setup page when you add or edit a goal or action. Under the Goal or Action Criteria heading, click the first dropdown menu for the Condition and then select Create New Calculated Field.
- Click the orange Create calculated field button at the top right of the page.
- Complete the fields:
- Name
- Event
- Calculation
- Event field, if applicable for your calculation
- Apply an optional tracking window if you want to perform a sum or count calculation on a rolling basis. The time zone for your tenant will apply to your calculated field’s tracking window.
- Tip: For details about the window types and when to use them, see Tracking Windows for Calculated Fields.
- If you applied a sliding window, then you can set a maximum value to be counted for each unit of your interval (e.g., each day in a 60 day interval).
- Add an optional active period if you want to set a start and end date for the calculation.
- Add filters if you only want events that meet specific criteria to be included in the calculation.
- Note: Filters can apply to event characteristics (e.g., revenue amount for a given purchase) or user characteristics (e.g., a count of the number of times a participant makes a purchase over $100)
- Review your selections and decide if you want to backfill the values for all participants.
- Click the orange Save button.
🔗 Example: Reward participants who make 3 or more purchases of at least $50 in one month after the referral was started
Scenario: You have a referral program and want to reward participants who frequently make sizable purchases soon after they’ve been referred. You determine that for your program, this means any participant who makes 3 or more purchases of at least $50 in the month after the referral starts. A calculated field can help you determine which of your participants meet this threshold and act as the basis for a program rule that issues these participants a reward.
Here’s how the calculation can be set up:
Under the Calculation heading, complete the Name field.
Enter the following values for the event and calculation fields:
- Event: Purchase
- Calculation: Count
Note: This will set up the calculation to count how many times we receive purchase events that meet your criteria.
Apply a fixed tracking window. This will cause the calculation to reset each month.
- Select Fixed Window.
- Choose a 1 calendar month window duration.
Add a filter to specify that you only want to count the purchase events with a value of $50 or more:
- Click Add Rule.
- For the first Condition dropdown, select the
events.fields.revenue
field. - Change the operator type to greater than or equal to.
- Enter
50
as the string variable value.
Tip: JSONata expressions only accept whole numbers. When using currency, we recommend using the lowest denomination used in your database configuration. If you’re not sure, contact our Support team for help.
Review and click Save.
The remaining setup must be done in your referral program. The exact steps to follow depend on the full program setup, but here’s the general process.
- Create or edit a goal.
- Set it to trigger when a referred user field updates.
- Under the Goal Criteria heading, click Add Rule.
- In the Condition dropdown box:
- Select your new calculated field
- Choose the operator greater than or equal to
- Enter
3
in the variable text box
The goal will only trigger now if we receive 3 or more purchase events with a revenue of $50.00 or more.
You can also add Action Criteria to only trigger the action if these events were received within the first month after we receive the referral started event.
🔗 Example: Reward participants the first time they have spent more than $1000 in the last 90 days
Scenario: You want to set up a program rule that rewards the highest-spending members of your Points program. You determine that anyone who spends over $1000 during a 90 day period meets that threshold. A calculated field can help you determine which members of your Points program hit this purchase threshold, and act as the basis for your program rule.
Here’s how the calculation can be set up:
- Under the Calculation heading, complete the Name field.
- Enter the following values for the event and calculation fields:
- Event: Purchase
- Calculation: Sum
- Event field: Revenue
Note: This will set up the calculation to sum the
revenue
field for each purchase event
- Apply a sliding tracking window of 90 days.
- Select Sliding Window.
- Use the slider or dropdown menus to set the window duration at 90 days.
- Review and click Save.
The remaining setup can be done in your Points program rules. The exact steps to follow depend on the full program setup, but here’s the general process.
- Create or edit a goal.
- Set it to trigger on a referred user field update.
- Set the edge triggering to be the name of the calculated field you just created (e.g.,
user.customFields.90DayTotal
). - Under the Goal Criteria heading, click Add Rule.
- In the Condition dropdown box:
- Select your new calculated field
- Choose the operator greater than or equal to
- Enter
1000
in the variable text box
Tip: JSONata expressions only accept whole numbers. When using currency, we recommend using the lowest denomination used in your database configuration. If you’re not sure, contact our Support team for help.
The goal will now trigger only if the user has made $1000 in purchases over the previous 90 days.