#  Other Applications & Softwares  > Word Formatting & General >  >  Can we use OR formula with IF in the merge field....

## adil.master

Hi,

This is related to Mail Merging a document with specified conditions.

I tried to explore the forum but couldnt find my answer.... Hope someone can provide a solution to my query.

I have a Word document which have certain merge fields like "Name" "Address" "City" "State" etc. learned how to use the IF formula in the merge field for eg.

{IF {MERGEFIELD State} = "A" "Paragraph 1." "{IF {MERGEFIELD State} = "B" "Paragraph 2." " "} "}

however what I am searching for is that can the function "OR" be added in the "IF" function like we do it in EXCEL for eg:

IF(OR(MERGEFIELD State = "A" OR MERGEFIELD State = "C" OR MERGEFIELD State = "E") than "Paragraph 1"  and then again followed by IF....


Your quick response will be highly apprecaited.... Thank you.

----------


## ajryan88

Hi!

Try the following layout for your formula:

```
Please Login or Register  to view this content.
```

Hope this helps  :Smilie: 

EDIT: Sorry, ignore this I didn't read your OP correctly the first time. I actually can't help you because I have not dealt with mail merges before. I just can't work out how to delete my post. Sorry!

----------


## macropod

You can use field coding like:
{IF{IF{MERGEFIELD State}= "A" 1 0}+{IF{MERGEFIELD State}= "C" 1 0}+{IF{MERGEFIELD State}= "E" 1 0}= 1 "Paragraph 1" "Paragraph 2"}

*Note*: The field brace pairs (ie '{ }') for the above example are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this message.

----------


## adil.master

Thank you very very much for responding to my query...
however i am just trying to understand it a little more... what are the '1 0' (highlighted below) that you have entered at the end of every brace? Thanks again for your time.  :Smilie: 

{IF{IF{MERGEFIELD State}= "A" *1 0*}+{IF{MERGEFIELD State}= "C"* 1 0*}+{IF{MERGEFIELD State}= "E"* 1 0*}= 1 "Paragraph 1" "Paragraph 2"}

----------


## macropod

Basically, what you have is a series of IF tests of the 'State' mergefield. With {IF{MERGEFIELD State}= "A" 1 0}, for example, the IF test outputs 1 if the State is A and 0 otherwise. The results of these three IF tests are added together (e.g. 1+0+0 = 1 or 0+1+0 = 1 or 0+0+0 = 0) and compared against '1' in another IF test to determine the ultimate output.

----------

