Skip to main content
Calculations — previously called Invisible Logic — let you create new variables whose values Gavel computes automatically, without asking the client another question. You define a formula or a set of conditional rules, and Gavel evaluates them behind the scenes to produce a value that you can use anywhere in your document templates or question logic. This is the tool to reach for whenever you need to derive information from what the client already told you, rather than asking for it directly. You access Calculations from the Calculations page at the top of the screen when editing a workflow.

Why use Calculations?

Gavel can perform arithmetic on numeric answers so you don’t have to ask for derived values. For example, divide an annual salary by 12 to produce a monthly figure, then reference that computed variable in your document.
Merge separate fields — such as first name, middle name, and last name — into a single full-name variable. You collect the parts once and reference the assembled whole wherever you need it, without asking the client for their full name again.
Set a variable to different text values depending on conditions. The classic use case for legal documents is pronouns: assign “He,” “His,” and “Testator” or “She,” “Her,” and “Testatrix” based on the client’s stated gender.
Calculate deadline dates, ages, or eligibility dates automatically. For example, compute whether a client’s birthday means they were under 18 as of today, and use that result to control what pages they see.

Creating a Calculation variable

1

Open the Calculations page

While editing your workflow, click the Calculations tab at the top of the screen.
2

Create a new variable

Add a new Calculation variable and give it a name. Choose the variable type (Text, Number, Date, etc.) to match the kind of value you want to produce.
3

Enter the fallback formula

In the formula field, enter the value the variable should have when no specific condition is met. For a conditional variable, this is typically an empty string " ". For a straightforward formula with no conditions, enter the expression directly here.To insert values in the formula field, click inside it to see a dropdown menu:
  • Click Enter text to type a text literal (Gavel adds the quotation marks)
  • Click Enter space to insert a blank space " "
  • Click a variable name (prefixed with @) to reference any existing variable
  • Scroll down to find functions such as add, concatenate, or format date
4

Add conditional logic (optional)

Click Add Logic to define conditions under which the variable should take a different value. Each condition specifies: when [variable] equals [value], set this Calculation variable to [output].You can group multiple Calculation variables together and apply the same logical condition to all of them at once — useful when a single condition (such as gender) drives several related variables (pronoun, possessive, title).
Each Calculation variable requires a fallback value. If your logic panel appears blank when you return to edit it, check that you have set a fallback in the formula field. This is often just an empty string for text variables.

Referencing Calculation variables in documents

You reference Calculation variables in your DOCX or PDF templates using the same double-curly-bracket syntax you use for any regular questionnaire variable:
{{ CalculationVariableName }}
Calculation variables work seamlessly across your entire workflow — in document templates, question logic conditions, and instruction blocks.

Setting conditions for pronouns

Handling pronouns is one of the most common Calculations use cases in legal document automation. Instead of scattering conditional logic throughout your template, you create a small group of pronoun variables in Calculations and then reference those variables everywhere a pronoun appears.
1

Ask for gender

Add a single-select question with a variable such as ClientGender and choices like Male, Female, and Non-binary.
2

Create a pronoun Calculations group

In Calculations, create a group of new variables for the pronoun forms you need. For a will or trust, you might create:
  • ClientPronounSubject (He / She / They)
  • ClientPronounPossessive (His / Her / Their)
  • ClientTitle (Testator / Testatrix / Testator)
3

Set the conditional logic

Add logic to the group:
ConditionClientPronounSubjectClientPronounPossessiveClientTitle
ClientGender == "Male"HeHisTestator
ClientGender == "Female"SheHerTestatrix
ClientGender == "Non-binary"TheyTheirTestator
Set the fallback for each variable to an empty string.
4

Repeat for additional parties

Create a second Calculations group for spouse pronouns, following the same pattern with a SpouseGender question as the source.
5

Use the variables in your template

Reference the pronoun variables anywhere in your document:
{{ ClientTitle }} hereby declares that {{ ClientPronounSubject }} is of sound mind
and wishes to dispose of {{ ClientPronounPossessive }} estate as follows.

Numerical calculations

For numeric computations in your document templates, you can write mathematical expressions directly in your template using double curly brackets. Make sure the source questions use the Number or Integer question type.
{{ (variable1 + variable2)|float }}
Displays the sum of two variables as a decimal number.
When combining rounding with number formatting, place the rounding call inside the parentheses:
{{ "{:,.0f}".format(variablename|round(0,'ceil')) }}

Date calculations

Gavel provides a full set of date-calculation functions you can use directly in document templates.

Calculate age or time elapsed

{{ (date_difference(starting=DateVariable).years|int) }}
Outputs the number of whole years between a date variable and today. This is the standard pattern for calculating a client’s age from their date of birth.

Calculate between two specific dates

{{ (date_difference(starting=StartDate, ending=EndDate).years|int) }}

Add or subtract days, months, or years

{{ format_date( (DateVariable) + date_interval(years=2) ) }}
Use - instead of + to subtract. You can substitute years, months, days, or weeks for the unit. This is especially useful for computing statute of limitations deadlines and notice periods.

Add or subtract business days

{{ format_date( (DateVariable) + date_interval(bus_days=10) ) }}

Calculate months between two dates

{{ (relative_date_difference(starting=StartDate, ending=EndDate).months) }}

Find the next or prior business day

{{ next_business_day(DateVariable) }}
{{ prior_business_day(DateVariable) }}

Date-based conditional eligibility

You can use Calculations to create eligibility date variables and then drive page logic from them. For example, an attorney who only represents minors can compute:
eligibility_date = today() - date_interval(years=18)
Then set a page condition of client_birthday > eligibility_date to show the minor-specific page only to qualifying clients.

Display conditional messages based on dates (in questions)

In instruction blocks within your questionnaire, you can show different text based on a date comparison:
${ "We are sorry. You are too late." if date_difference(starting=FilingDate).days > 30 else "Great. Let's continue." }

${ "You made it before the deadline" if DateVariable > as_datetime("2025-12-31") else "You are past the deadline." }