6

I have seen other similar questions about calculated fields/columns and Yes/No fields, but only regarding syntax. I don't have an issue with the syntax (I think) but I can't get an IF statement to work with a Yes/No field.

My formula is pretty simple:

=IF([YesNoFieldA]="Yes","Print Some Text","Print some other text")

This forumula always returns the false value ("Print some other text").

When I set the formula to:

=[YesNoFieldA]  

A "Yes" or "No" are always returned.

Is this a known bug, or are Yes/No fields just quirky and I can't figure them out?

1
  • 3
    For the record I loathe the yes no field, it is displayed as yes/no, stored as true/false, and is referenced in places as 1/0. I prefer to use an actual choice field instead for consistancy whenever possible. Jan 30, 2014 at 18:48

2 Answers 2

9

Yes/No fields are internally stored as bit/boolean. So your first attempt of comparing the value to a string "Yes", is correctly evaluating to false, then resulting in "Print some other text" returned.

If you use this formula, then a boolean comparison will be performed, thus giving you the expected result:

=IF([YesNo],"Print Some Text","Print some other text")
1
  • Thanks for the answer. I'm not a programmer by trade and this would have never occurred to me.
    – Sam
    Jan 30, 2014 at 16:36
4

Although the fields are called Yes/No fields their values are actually Boolean (i.e. TRUE/ FALSE). If you were using a different language version of SharePoint Yes/No would be translated into that language.

If you change your formula to:

=IF([YesNoFieldA]=TRUE,"Print Some Text","Print some other text")

all will be well in the world

2
  • I had tried this earlier and it didn't work.
    – Sam
    Jan 30, 2014 at 17:00
  • 1
    SammyB - this does work, you probably used "TRUE" and not TRUE
    – Ryan
    Apr 9, 2015 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.