Documate is now Gavel! Read more about why we’re excited about this rebrand.

Docassemble: Templating Word documents (Part III, Numerical Calculations)

How to use Jinja and Mako syntax in Word document templates used in Docassemble to perform calculations.

Documate is a no-code solution to creating Docassemble interviews. One of the biggest challenges to using Docassemble, the powerful document assembly platform, is knowing how to use Jinja and Mako syntaxes in your Word (.docx) documents so that you can customize your legal documents and agreements. Here we teach you how to use Jinja in your Docassemble word documents to template numerical calculations.

In our series of posts about templating Word documents for use in Docassemble, we are showing you the most commonly used syntax for lawyers. In Parts I and II of this series, we taught you how to set up simple variables, conditional phrases, and conditional paragraphs in your documents. This articles shows you how to perform calculations in your documents.

Want to calculate the numerical value for a field based on prior variables?  You can do so by entering your mathematical equation in the format below. Remember to set your variables as Integers or Numbers.  Make sure any subtractions signs "-" are not extended automatically in Microsoft Word to a longer dash.

Adding and Subtracting Variables

This equation adds variables 1 and 2 and subtracts variable 3.

{{ variable1 + variable2 - variable3 | float }}

Multiplying and Dividing Variables

This syntax multiplies 100 times variable1 divided by variable 2. This is a helpful format for percentages.

{{ 100 * variable1 / variable2 | float }}

Stay tuned for our next article on formatting numbers and currency! Please don't hesitate to contact us with questions at [email protected] or (415) 322-0975.

Documate makes it easy to create Docassemble interviews without using any code.  Documate's Word add-in is also available in the Microsoft app store for Docassemble templating of calculations and numbers, which eliminates the need to use Jinja syntax.

If you haven't already, check out the rest of our Docassemble resources:

Resources for Docassemble Developers

Jinja Guide Part I: Simple variables and conditional phrases

Jinja Guide Part II: Conditional paragraphs

Jinja Guide Part III: Performing calculations

Jinja Guide Part IV: Numerical calculations

Jinja Guide Part V: Formatting words

Documate Newsletter

Sign up for our newsletter to get product updates, exclusive client interviews, and more.

By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.