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. Jay Freedman 206K Reputation points Volunteer Moderator
    2021-11-15T17:45:42+00:00

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

    No, that is not correct. DO NOT start from Insert > Mergefield. That's only for making a Mail Merge document.

    You can use Insert > Quick Parts > Field > Ref and choose Retention in the Bookmark Name box:

    The result is the field code { REF Retention }.

    But that's the hard way, especially when you need to do it lots of times. The REF keyword in the field's code is optional, so a pair of field braces with just a bookmark name inside, {Retention}, is the same as including REF. But notice that it has braces like { } and not chevrons « » like a merge field.

    The easy way is to press Ctrl+F9 (or Ctrl+Fn+F9 on some laptops) to insert the field braces -- note that you can't make a field by just typing the braces -- and then type the bookmark name between them. And when you need lots of the same field, you can copy the first one and paste it in other places as needed.

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2021-11-18T07:01:14+00:00

    Hi,

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

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

    Best Regards,

    Ethan

    0 comments No comments