Using IF functions in word

Anonymous
2021-11-10T15:45:49+00:00

Hello,

I am a complete beginner trying to make an IF statement in microsoft word. I want to be able to input a number into a table and a specific condition to appear based on the number that was input as shown in the below table. (Input on the left and the output on the right.)

≤ 0.3 2 - 10 %
0.3 - 0.4 5 - 10 %
0.40 - 0.45 5 - 25 %
0.45 - 0.60 10 - 30 %
0.60 - 0.70 20 - 40 %
0.70 - 0.80 25 - 50 %
0.80 - 1.00 30 - 60 %
1.00 - 1.20 40 - 80 %
1.20 - 1.40 50 - 95 %
1.40 - 1.45 60 - 100 %
≥ 1.5 70 - 100 %

As a test, I tried IF "Expression 1" = "Expression 2" "True "False" however my values kept appearing as false and I am not sure why?

Any help that could be provided would be greatly appreciated!

Thanks,

John

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Jay Freedman 206K Reputation points Volunteer Moderator
    2021-11-10T20:57:04+00:00

    I gather that the expressions in the left column are the conditions that correspond to the outputs in the right column, and you want to step through the conditions until you find the one that matches the single input value.

    To handle that, first insert a legacy form field in the template or document you're working on. I would set it to Number type, format 0.00, name the bookmark Input, and check the boxes "Fill-in enabled" and "Calculate on exit". (The bookmark name is your choice, but make it short because you're going to have to repeat it a lot of times in the output field.)

    In the output cell, you need a set of nested IF fields, with each condition nested into the FALSE part of the IF field before it. The first few nestings go like this:

    { IF { Input } <= 0.3 "2 - 10 %" { IF { Input } <= 0.4 "5 - 10 %" { IF { Input } <= 0.45 "5 - 25 %" } { IF { Input } <= 0.6 "10 - 30 %" <the next IF field goes here> } } }

    The FALSE part of the most deeply nested IF field is just "70 - 100 %". Note that your list has a gap between 1.45 and ≥ 1.5 that should be expressed as IF { Input } ≤ 1.5 .

    To make the form field operational, protect the document for filling in forms.

    There is an alternative method that involves using content controls instead of fields, and writing a Document_ContentControlOnExit macro to take the place of the IF fields. This can be easier to write and to understand, and doesn't require locking the document. Post back if you want instructions for this.

    3 people found this answer helpful.
    0 comments No comments

10 additional answers

Sort by: Most helpful
  1. Charles Kenyon 159.8K Reputation points Volunteer Moderator
    2021-11-11T20:45:25+00:00

    Like Jay, I would urge you to switch to Content Controls.

    0 comments No comments
  2. Anonymous
    2021-11-15T08:19:59+00:00

    Hi,

    I wrote this reply to follow up on this thread. Have you checked Jay Freedman’s last reply?

    Has your problem been resolved? I look forward to your reply!

    Best Regards,

    Ethan

    0 comments No comments
  3. Anonymous
    2021-11-15T15:57:48+00:00

    Hi Jay,

    I tried to follow the first approach you provided doing the following steps:

    Firstly, I set the legacy field as shown below

    Image

    Secondly, I setup an IF function under gradient

    Image

    The I restricted the document for editing and typed in a value under retention, however the IF function did not perform as expected?

    Image

    Was just wondering what I did wrong? How do I go about testing my IF functions? I have managed to get the IF functions to work in excel but just cant seem to get it to work in Word?

    For {Retention} I have been doing this by going to Insert > Mergefield > Name: 'Retention' is this the correct way of doing this?

    I will try the content controls approach at a later time but would like to get the nested IF functions to work so any help you could provide would be greatly appreciated!

    Kind regards,

    John

    0 comments No comments
  4. Anonymous
    2021-11-15T16:51:54+00:00

    Hi Jay,

    Just to confirm this method has worked for me so thanks for all the support you've given me!

    Would still like to get to the bottom of the IF functions approach if possible as I might need to repeat this sort of logic further down the form :)

    Kind regards,

    John

    0 comments No comments