How to Calculate 20% and 80% of Invoice Totals Using Word Field Codes
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.

- 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.
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.
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.
Click where you want the 20% calculation to appear in your document and press Ctrl + F9. This will insert the outer field braces { }.
Inside the outer braces, type the formula to calculate 20 percent: '= .2 * '. If you are calculating 80 percent, type '= .8 * ' instead.
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'.
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)" }.
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.

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. Open your invoice template: Download and launch WPS Office, then open your existing .docx invoice template.
- 2. Insert field codes: Navigate to the Insert tab or directly press Ctrl + F9 to add functional field boundaries into your document.
- 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. Toggle the display: Press Alt + F9 to instantly switch between viewing the raw field codes and the dynamically calculated invoice amounts.

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.




