Forum Discussion
Need help with nested IF/AND statement for a Calculated Column
- Sep 18, 2019
Jon Gertken It's very easy to get tangled up in quotes and missing parens. Plus, you can only next about 7 IF statements, so that makes it more difficult.
What I've done in the past is rethink it a bit to make the syntax a bit easier. I'd count how many of the fields are 'Approved' and then do the logic.
That part would look like:
=IF([column1]="Approved",1,0)+IF([column2]="Approved",1,0)+IF([column3]="Approved",1,0)+IF([column4]="Approved",1,0)+IF([column5]="Approved",1,0)+IF([column6]="Approved",1,0)+IF([column7]="Approved",1,0)
If a column is 'Approved', it adds one to the total, if not, it adds 0. This works because you are using the + for adding.
Then, wrap that whole thing in a IF(<codeFromAbove>=7,"Approved","Pending"), so the full thing would look like:
=IF(IF([column1]="Approved",1,0)+IF([column2]="Approved",1,0)+IF([column3]="Approved",1,0)+IF([column4]="Approved",1,0)+IF([column5]="Approved",1,0)+IF([column6]="Approved",1,0)+IF([column7]="Approved",1,0)=7,"Approved","Pending")
Jon Gertken It's very easy to get tangled up in quotes and missing parens. Plus, you can only next about 7 IF statements, so that makes it more difficult.
What I've done in the past is rethink it a bit to make the syntax a bit easier. I'd count how many of the fields are 'Approved' and then do the logic.
That part would look like:
=IF([column1]="Approved",1,0)+IF([column2]="Approved",1,0)+IF([column3]="Approved",1,0)+IF([column4]="Approved",1,0)+IF([column5]="Approved",1,0)+IF([column6]="Approved",1,0)+IF([column7]="Approved",1,0)
If a column is 'Approved', it adds one to the total, if not, it adds 0. This works because you are using the + for adding.
Then, wrap that whole thing in a IF(<codeFromAbove>=7,"Approved","Pending"), so the full thing would look like:
=IF(IF([column1]="Approved",1,0)+IF([column2]="Approved",1,0)+IF([column3]="Approved",1,0)+IF([column4]="Approved",1,0)+IF([column5]="Approved",1,0)+IF([column6]="Approved",1,0)+IF([column7]="Approved",1,0)=7,"Approved","Pending")
Thanks a million, saved me some headache. Had to tweak it a little but works like a charm.