Microsoft KB Archive/90488

= WD: Performing Calculations in a Mail Merge Field =

Article ID: 90488

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Word 1.0 Standard Edition
 * Microsoft Word 1.1 Standard Edition
 * Microsoft Word 1.1 Standard Edition
 * Microsoft Word 2.0 Standard Edition
 * Microsoft Word 2.0a
 * Microsoft Office Word 2003
 * Microsoft Word 2.0c
 * Microsoft Word 6.0 Standard Edition
 * Microsoft Word 6.0a
 * Microsoft Word 6.0c
 * Microsoft Word 95 Standard Edition
 * Microsoft Word 95a
 * Microsoft Word 97 Standard Edition

-



This article was previously published under Q90488



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} = &quot;NY&quot; {=({MERGEFIELD amnt} * .825}  {=({Mergefield amnt} * .725)}} General: {IF {Mergefield name} = &quot;Mergefield&quot; {=({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 &quot;Expression Field,&quot; or see page 304 of the version 2.0 &quot;Microsoft Word for Windows User's Guide,&quot; or see pages 27 and 95-96 of the versions 1.x &quot;Microsoft Word for Windows User's Reference.&quot;

