---
title: "Rule Formulas"
slug: "rule-formulas"
updated: 2026-03-25T16:33:41Z
published: 2026-03-25T16:33:41Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.technolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Rule Formulas

Rule Formulas allow you to use a combination of exports to set a value. Formulas are supported with the following Rule Types:

- Field
- Application Header
- Person Header
- Person Index
- Dataset Index/Header
- Dataset Username
- Dataset Name

This article will first explain how Formulas work, as the usage is exactly the same regardless of the Rule Type, and then it will provide some examples.

> [!WARNING]
> A note about field rules
> 
> Rule formulas do not work with all fields. In general, prompt-driven fields cannot be set using a rule formula. The exception are fields that use country, language, state, or user as their prompt setting. These special prompts are discussed later in the article.

## How Formulas Work

When the **Action** of a Rule is set to **Replace Values from Formula**, you are presented with the ability to add Exports and Joins.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/image-WZYJXLKI.png)

You can add base joins (one-to-one joins) and any direct exports or subquery exports as needed. Exports must have a name with no spaces or special characters.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-09 at 4.16.31 PM.png)

To use the exports in the formula, add an @ symbol in front of the export name. For example: **@ref_id**.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-09 at 4.57.24 PM.png)

Click Join or the subquery join icon to join to create a one-to-one base join. Unlike in the query tool, base joins will appear above the exports, but they still represent a one-to-one join and will only return data from one related row.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-10 at 4.46.33 PM-1.png)

## Simple Formula Rules

In many cases, the formula can be constructed entirely within a subquery export.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-10 at 4.34.22 PM.png)

There many benefits to this approach:

- You might not need to write a formula at all. For example, by using the Coalesce or Concatenate output setting.
- You can configure your subquery export just like you would in a query, giving you familiarity and minimizing possible mistakes.
- It can simplify the logic since only one item is needed.

A good example is a [Person Header](/v1/docs/person-indexheader-rules-customizing-person-record-search-criteria) rule. This type of rule can customize the text that appears under a person’s name when using omni search.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/image-C3HFOL7K.png)

The value shown in the screenshot is the default. Here is how it would be built within a subquery export:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/image-A4GGIMA4.png)

## Complex Formula Rules

Rule formulas can use the exact same formula elements as [formulas in queries](/v1/docs/using-formulas-in-queries). The linked article discusses formula formatting and common use cases.

### Example: Performing Calculations

Rules can perform [mathematical operations](https://knowledge.technolutions.net/v1/docs/en/using-formulas-in-queries#mathematical-operations) like addition (+), subtraction (-), multiplication (*), division (*), and modulo (%). When writing mathematical formulas, always confirm the data type of each element to make sure that they will be treated as numbers (Integer or Real).

Mathematical operations can be performed with a simple formula by using a subquery export. For example, if we have a Scholarships entity, we can Sum all of the values in the Amount field:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-10 at 4.57.28 PM.png)

However, we may have data in more than one place. In this example, we also have a flat field that stores the value of the Presidential Scholarship, which is not included in the Scholarships entity. After adding it as an export, we have the following formula:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-10 at 5.00.43 PM.png)

Make sure to choose the correct Format Type for each export. A numeric format (Real, Integer, or Money) must be chosen in order for the calculation to work.

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-10 at 5.14.14 PM.png)

## Special Prompt Values

Most prompt-driven fields can’t be set with a rule formula, since they store the GUID of the selected prompt. The following prompts are stored as text, allowing them to be set via formula:

- **country**fields store the two-letter country code (e.g. “US”). Although these are not GUIDs, the codes can be found using the “GUID” export on the System > World - Country base.
- **language**fields store the two-letter language code (e.g. “EN”). These codes are the Index values on the “language” prompt, which can be queried using the System > Prompt base.
- **state** fields store the two-letter state code (e.g. “OR”). These codes can be found using the “Alpha2” export on the System > World - Region base.
- **user**fields store usernames. These can be found using the “Username” export on the Related > User base.

### Example: Staff Assignment by Formula

In this example, a [translation code](/v1/docs/fields-and-prompts-translation-codes) exists to associate states with Slate users. We’ve set this up using the [translation code source format](/v1/docs/translation-code-import-source-format) to easily populate our values:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-11 at 12.49.28 PM.png)

In a rule with a type of Field, scroll to the **Field** dropdown and select your Staff Assigned field. In the **Action** dropdown, select **Replace Values from Formula**. To create an export to display the student’s state, we’ll make a base join to Address by Rank Overall and choose the rank 1 address. Next, we’ll add the export for Region:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-11 at 12.52.58 PM.png)

We now need to edit this export to give it a machine-friendly name (no spaces) and apply the translation code:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/image-NM77EMYM.png)

Our rule is now almost complete. We just need to add the export to the formula using the @ symbol:

![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Screenshot 2025-04-11 at 12.55.41 PM.png)

That’s it! Our rule uses the student’s address, looks up the relevant staff member using the translation code, and sets the Staff Assigned field - all with a very simple formula and no subqueries needed.
