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?

Robert Lindgren
  • 24,520
  • 12
  • 53
  • 79
Sam
  • 193
  • 1
  • 1
  • 5
  • 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. – Eric Alexander Jan 30 '14 at 18:48

2 Answers2

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")
MdMazzotti
  • 4,787
  • 3
  • 17
  • 35
  • Thanks for the answer. I'm not a programmer by trade and this would have never occurred to me. – Sam Jan 30 '14 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

Chaholl
  • 311
  • 1
  • 2