Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
1  
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. –  PirateEric Jan 30 at 18:48

2 Answers 2

up vote 0 down vote accepted

It is definitely not a bug, I don't see anything strange or wrong in this behavior.

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")
share|improve this answer
    
Thanks for the answer. I'm not a programmer by trade and this would have never occurred to me. –  SammyB Jan 30 at 16:36
    
Glad it helped :) (mark the answer as accepted if you found it helpful) –  MdMazzotti Jan 30 at 16:37

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

share|improve this answer
    
I had tried this earlier and it didn't work. –  SammyB Jan 30 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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