WD: Performing Calculations in a Mail Merge Field

ID: Q90488

The information in this article applies to:

SUMMARY

Word can perform calculations using the values from bookmarks or print merge MERGEFIELD fields.

MORE INFORMATION

You can use an EXPRESSION (=) field to perform calculations on the values represented by bookmarks or print merge fields. For example, to multiply the value in the Term field by 2, insert the following field:

   {=Term * 2}

To make a calculation using a MERGEFIELD field, use the following format (versions 2.0 and later of Word for Windows only):

   {= ({MERGEFIELD order} + 100)}

Note that the MERGEFIELD field is nested in the EXPRESSION field. The result of the calculation appears in the print merged documents.

Multiple Calculations in an EXPRESSION Field

You can perform multiple calculations in one EXPRESSION field. The below sample will multiply .825 by the {Mergefield amnt} if the {Mergefield state} is equal to NY otherwise it will multiply {Mergefield amnt} by .725 if it is any other state.

   {IF {MERGEFIELD State} = "NY" {=({MERGEFIELD amnt} * .825}
   {=({Mergefield amnt} * .725)}}

General:

   {IF {Mergefield name} = "Mergefield" {=({Mergefield name} * .825} Else
   {=({Mergefield name} * .725)}}

Below is a sample table.

   State amnt
   NY    100
   TX    100

Multiple Fields in an EXPRESSION Field

You can use two or more bookmark or MERGEFIELD fields in EXPRESSION fields. In the following examples, if the value of FIELD1 is 100 and the value of FIELD2 is 200, the result of the calculation, or 300, appears in the print merged document:

   {=BOOKMARK1 + BOOKMARK2}

   {={MERGEFIELD FIELD1} + {MERGEFIELD FIELD2}}

For more information about the operators you can use in mathematical calculations, use the Help menu to search on "Expression Field," or see page 304 of the version 2.0 "Microsoft Word for Windows User's Guide," or see pages 27 and 95-96 of the versions 1.x "Microsoft Word for Windows User's Reference."

REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, page 304

"Microsoft Word for Windows User's Reference," version 1.x, pages 27, 95-96

"Microsoft Word for Windows and OS/2 Technical Reference," pages 336- 342

KBCategory: kbusage KBSubcategory: kbfield kbmerge Additional query words: 1.0 1.10 1.10a 2.0 2.0a 2.0c 6.0 6.0a 6.0c 7.0 winword2 winword word7 word6 word95 mail add subtract multiply divide math formula word97

Keywords          : kbualink97 kbusage kbfield kbmerge 
Version           : 1.x 2.x 6.0 6.0a 6.0c 7.0 7.
Platform          : WINDOWS

Last Reviewed: February 6, 1998