Link to home
Start Free TrialLog in
Avatar of Kathleen Boilek
Kathleen Boilek

asked on

Nested IF statements for Validation Settings in SharePoint 2013

I am attempting to implement the validation settings for 5 columns in SharePoint 2013.  I am having problems nesting the IF statements.  Each line works but when I link them together the textbox doesn't except the value and still states location required.
Here is the code:
=IF([Mon Status]="OH",TRUE,IF([Mon Location]<>"",TRUE,FALSE))
IF([Tue Status]="OH",TRUE, IF([TueLocation]<>"",TRUE,FALSE))
IF([Wed Status]="OH",TRUE, IF([Wed Location]<>"",TRUE,FALSE))
IF([Thu Status]="OH",TRUE, IF([Thu Location]<>"",TRUE,FALSE))  
IF([Fri Status]="OH",TRUE, IF([Fri Location]<>"",TRUE,FALSE))
Avatar of Norie
Norie

Kathleen

Have you looked at using AND/OR?

For example, if you wanted to check if any of the status fields were empty you could use something like this:

=OR([Mon Status]="", [Tue Status]="", [Wed Status]="", [Thu Status]="", [Fri Status]="")

If you can outline the logic behind the validation we could probably help further.
Avatar of Kathleen Boilek

ASKER

Hi Norie,
Yes I did try AND/OR but no luck.  
Mon Status is a dropdown and if other than OH is selected, the Mon Location textbox is required.  I am very poor with nested IF statements.  I assumed I could use the same line of code =IF([Mon Status]="OH",TRUE,IF([Mon Location]<>"",TRUE,FALSE)) and add the others within the IF statement.
Does this help?
I managed to come up with this:  =IF(AND([Mon Status]="OH", [Tue Status]="OH", [Wed Status]="OH", [Thu Status]="OH", [Fri Status]="OH"),TRUE,IF(AND([Mon Location]<>"", [TueLocation]<>"", [Wed Location]<>"", [Thu Location]<>"", [Fri Location]<>""),TRUE,FALSE)), the formula clears with no errors.  When I open up the form to select other choice other than OH, it prompts me Location is required.  I enter the location and click on save, the form doesn't want to save and close.
Kathleen

So you want to check the status field for each day?

If it's 'OH' return TRUE, if it's anything other than 'OH' then return TRUE if the corresponding location field is not blank?

Perhaps:

=IF(AND(OR(AND([@[Mon Status]]="OH", [@[Mon Location]]=""),[@[Mon Location]]<>""),OR(AND([@[Tue Status]]="OH", [@[Tue Location]]=""),[@[Tue Location]]<>""),OR(AND([@[Wed Status]]="OH", [@[Wed Location]]=""),[@[Wed Location]]<>""),OR(AND([@[Thu Status]]="OH", [@[Thu Location]]=""),[@[Thu Location]]<>""),OR(AND([@[Fri Status]]="OH", [@[Fri Location]]=""),[@[Fri Location]]<>"")), TRUE, FALSE)
Thank you Norie, yes and I'll try your suggestion tomorrow and let you know the results.
Didn't work.  Using the @ signs, I received an error stating columns didn't exist.  When I removed the @ signs, the form does validate however, form doesn't save.  Gotta love SharePoint 2013.
I have also tried:  
=IF(AND(OR([Mon Status]="OH", [Tue Status]="OH", [Wed Status]="OH", [Thu Status]="OH", [Fri Status]="OH")),TRUE,IF(AND(OR([Mon Location]<>"", [TueLocation]<>"", [Wed Location]<>"", [Thu Location]<>"", [Fri Location]<>"")),TRUE,FALSE))

and the form refuses to save as well.  I only know that this formula IF([Tue Status]="OH",TRUE, IF([TueLocation]<>"",TRUE,FALSE)) definitly works. The form is validated and is saved.
Kathleen

Sorry, totally forgot about the @, I was testing the logic using a table in Excel and forgot to remove them before posting the formula.

Did you also remove the extra set of [] around the column names?
Yes ma'am I did.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.