WD: Performing Calculations in a Mail Merge Field (90488)



The information in this article applies to:

  • Microsoft Word for Windows 1.0
  • Microsoft Word for Windows 1.1
  • Microsoft Word for Windows 1.1a
  • Microsoft Word for Windows 2.0
  • Microsoft Word for Windows 2.0a
  • Microsoft Word for Windows 2.0b
  • Microsoft Word for Windows 2.0c
  • Microsoft Word for Windows 6.0
  • Microsoft Word for Windows 6.0a
  • Microsoft Word for Windows 6.0c
  • Microsoft Word for Windows 95
  • Microsoft Word for Windows 95 7.0a
  • Microsoft Word 97 for Windows

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} = "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

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:kbfield kbmerge kbualink97 kbusage KB90488