Skip to main content
All CollectionsContactsAdvanced
Mail Merge (advanced)
Mail Merge (advanced)

Using conditional merge fields

James Webster avatar
Written by James Webster
Updated over 7 years ago

NB: This article is primarily aimed at those using the Microsoft Office application suite, however the principles are the same for many other packages.

When an organisation is working with Mail Merge, sometimes the information isn't quite in the format needed. At this stage there are three options:

  1. Enforce a format as part of data collection (e.g. only use 4 lines to capture address)

  2. Manually edit the exported data to fit the merge template

  3. Use advanced mail merge features to deal with unusual data.

In Microsoft Word, merge templates can contain conditional merge fields, allowing rules to be applied prior to formatting a document.

Consider a simple case where a list of contacts have addresses of unknown length.

Person A has a simple, 4 line address, which should be formatted as:

Name
 Address line 1
 Town
 County
 Post Code

Person B has a more complicated address which runs to 7 lines - too many for a standard windowed envelope, or address label. Therefore it should be formatted as:

Name
 Address line 1, Address line 2
 Address line 3, Town
 County, Post Code
 Country

Following the instructions found in  this Microsoft Article on using an "IF" field in your merge template, we can set up our template as follows:

Note: this cannot be simply copied and pasted into your template as you will need to insert special "merge" characters rather than standard braces

{IF address_lines.3 <>"" "{address_lines.1}, {address_lines.2}" "{address_lines.1}"}

{IF address_lines.3 <>"" "{address_lines.3}, {locality}" "{address_lines.2}"}

{IF country <>""
 {IF country <> "UK"
 {IF address_lines.3 <> "" "{region}, {postal_code}" "{locality}, {region}"}
 {IF address_lines.3 <> "" "{region}" "{locality}"}}
 {IF address_lines.3 <> "" "{region}" "{locality}"}}

{IF country <>""
 {IF country <>"UK"
 {IF address_lines.3 <>"" "{country}" "{postal_code}, {country}"}
 {IF address_lines.3 <>"" "{postal_code}" "{region}, {postal_code}"}}
 {IF address_lines.3 <>"" "{postal_code}" "{region}, {postal_code}"}}

Using this handy feature you can change which fields your template uses based on what data is available.

For more information, Microsoft have also created a video tutorial that walks you through advanced mail/merge features step by step.

Did this answer your question?