logo
search
Document Editing Problems

How to Calculate 20% and 80% of Invoice Totals Using Word Field Codes

Adam DavisAdam Davis Oct 12, 2026 869 views

Question details

The user wants to use nested field codes to automatically calculate 20% and 80% of a specific merge field (InvoiceAmountDue) within a custom invoice template.

How to Calculate 20% and 80% of an Invoice Total Using Word Field Codes
Product
Microsoft Word
Device & OS
not provided
Scenario
Creating a custom invoice template that dynamically splits or calculates percentages of the total amount due using mail merge fields.
Observed behavior
Needs the correct syntax for nested calculation field codes to produce the expected 20% and 80% values, while avoiding 'Undefined Bookmark' errors when integrating with accounting software like Xero.
Before you start

Ensure you have the exact name of your data source merge field (e.g., InvoiceAmountDue) ready and that your template is connected to the correct mail merge source before inserting field codes.

Solution 1Recommended

Use nested field codes to calculate percentages

Insert specific nested formula fields to dynamically calculate percentages based on your mail merge data.

When working with custom templates, you cannot type the curly braces manually on the keyboard. They must be inserted using the keyboard shortcut to be recognized as functional field codes.

1
Insert the outer field code boundaries

Click where you want the 20% calculation to appear in your document and press Ctrl + F9. This will insert the outer field braces { }.

2
Enter the calculation formula

Inside the outer braces, type the formula to calculate 20 percent: '= .2 * '. If you are calculating 80 percent, type '= .8 * ' instead.

3
Nest the merge field inside the formula

Place your cursor immediately after the asterisk and space. Press Ctrl + F9 again to insert the inner braces { }. Inside these new braces, type 'MERGEFIELD InvoiceAmountDue'.

4
Add the number formatting switch

Move your cursor between the inner closing brace and the outer closing brace. Add a space, then type the formatting switch: \# ",0.00;(,0.00)". Your final code should look like this: { = .2 * { MERGEFIELD InvoiceAmountDue } \# ",0.00;(,0.00)" }.

5
Hide codes and update fields

Press Alt + F9 to toggle off the field code display and reveal the calculated results. You may also need to highlight the text and press F9 to refresh the calculations.

Use nested field codes to calculate percentages
Fixing Undefined Bookmark Errors: If you receive an 'Undefined Bookmark' error in external software like Xero, verify that the merge field name perfectly matches your data source and that you strictly used Ctrl+F9 to create all braces.
Advanced Template Editing

Create and Edit Custom Invoice Templates with WPS Office

WPS Writer offers full compatibility with Microsoft Word document formats (.docx), allowing you to seamlessly insert, edit, and update complex field codes and mail merge data for your professional invoice templates.

  1. 1. Open your invoice template: Download and launch WPS Office, then open your existing .docx invoice template.
  2. 2. Insert field codes: Navigate to the Insert tab or directly press Ctrl + F9 to add functional field boundaries into your document.
  3. 3. Build the calculation: Type your formula inside the braces and press Ctrl + F9 again to nest your specific mail merge fields, exactly as you would in Microsoft Word.
  4. 4. Toggle the display: Press Alt + F9 to instantly switch between viewing the raw field codes and the dynamically calculated invoice amounts.
Fully compatible with Microsoft Word .docx templates and field code syntaxSupports Ctrl+F9 nested field codes and advanced arithmetic formulasIncludes a powerful built-in Mail Merge feature to streamline mass mailingsLightweight, fast, and completely free for standard document processing tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why am I getting an 'Undefined Bookmark' error in my template?

This usually happens if the merge field name referenced inside the field code (like InvoiceAmountDue) doesn't exactly match the column header in your data source, or if the field code braces were manually typed on the keyboard instead of properly inserted using the Ctrl+F9 shortcut.

Can I manually type the curly brackets { } for field codes?

No, you cannot type the curly braces using standard keyboard characters. Word processing programs require you to use the Ctrl + F9 keyboard shortcut to insert functional field code boundaries. Manually typed brackets will be treated as regular text and formulas will fail.

How do I hide the formulas and show the actual calculated numbers?

Press Alt + F9 on your keyboard to toggle between displaying the raw field codes and viewing the actual calculated results in your document. Once toggled, you may also need to press F9 to update the field values.