Why use Calculations?
Automate mathematical computations
Automate mathematical computations
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.
Combine multiple answers into one variable
Combine multiple answers into one variable
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.
Create conditional variables for document logic
Create conditional variables for document logic
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.
Derive dates from other dates
Derive dates from other dates
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
Open the Calculations page
While editing your workflow, click the Calculations tab at the top of the screen.
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.
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
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: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.Ask for gender
Add a single-select question with a variable such as
ClientGender and choices like Male, Female, and Non-binary.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)
Set the conditional logic
Add logic to the group:
Set the fallback for each variable to an empty string.
| Condition | ClientPronounSubject | ClientPronounPossessive | ClientTitle |
|---|---|---|---|
ClientGender == "Male" | He | His | Testator |
ClientGender == "Female" | She | Her | Testatrix |
ClientGender == "Non-binary" | They | Their | Testator |
Repeat for additional parties
Create a second Calculations group for spouse pronouns, following the same pattern with a
SpouseGender question as the source.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.- Addition
- Multiplication / Division
- Round down
- Round up
- Exponentiation
Date calculations
Gavel provides a full set of date-calculation functions you can use directly in document templates.Calculate age or time elapsed
Calculate between two specific dates
Add or subtract days, months, or years
- 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
Calculate months between two dates
Find the next or prior business day
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:client_birthday > eligibility_date to show the minor-specific page only to qualifying clients.
