SOLVED

Need help with nested IF/AND statement for a Calculated Column

%3CLINGO-SUB%20id%3D%22lingo-sub-861306%22%20slang%3D%22en-US%22%3ENeed%20help%20with%20nested%20IF%2FAND%20statement%20for%20a%20Calculated%20Column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861306%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20having%20issues%20getting%20a%20calculated%20column%20to%20play%20nice.%20Basically%20in%20a%20list%20I%20have%207%20%22Approval%22%20columns%20that%20are%20populated%20via%20a%20Approval%20Flows.%20I'm%20wanting%20this%20calculated%20column%20to%20update%20to%20%22Approved%22%20once%20the%20other%207%20columns%20all%20switch%20to%20%22Approve%22.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20either%20get%20a%20syntax%20message%20when%20I%20try%20to%20save%20the%20formula.%20Or%20the%20few%20iterations%20when%20it%20does%20accept%20it%2C%20it%20isn't%20behaving%20as%20intended.%20I'm%20sure%20I'm%20missing%20something%20obvious%2C%20but%20banging%20my%20head%20on%20the%20desk%20at%20this%20point.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(%5BColumn1%5D%3DApprove%2CAND(%5BColumn2%5D%3DApprove%2CAND(%5BColumn3%5D%3DApprove%2CAND(%5BColumn4%5D%3DApprove%2CAND(%5BColumn5%5D%3DApprove%2CAND(%5BColumn6%5D%3DApprove%2CAND(%5BColumn7%5D%3DApprove%2C%20%22Approved%22%2C%22Pending%22)))))))%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-861306%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861440%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20nested%20IF%2FAND%20statement%20for%20a%20Calculated%20Column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861440%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F154055%22%20target%3D%22_blank%22%3E%40Jon%20Gertken%3C%2FA%3E%26nbsp%3BIt's%20very%20easy%20to%20get%20tangled%20up%20in%20quotes%20and%20missing%20parens.%20Plus%2C%20you%20can%20only%20next%20about%207%20IF%20statements%2C%20so%20that%20makes%20it%20more%20difficult.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I've%20done%20in%20the%20past%20is%20rethink%20it%20a%20bit%20to%20make%20the%20syntax%20a%20bit%20easier.%20I'd%20count%20how%20many%20of%20the%20fields%20are%20'Approved'%20and%20then%20do%20the%20logic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20part%20would%20look%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DIF(%5Bcolumn1%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn2%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn3%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn4%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn5%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn6%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn7%5D%3D%22Approved%22%2C1%2C0)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20a%20column%20is%20'Approved'%2C%20it%20adds%20one%20to%20the%20total%2C%20if%20not%2C%20it%20adds%200.%20This%20works%20because%20you%20are%20using%20the%20%2B%20for%20adding.%3C%2FP%3E%3CP%3EThen%2C%20wrap%20that%20whole%20thing%20in%20a%20IF(%3CCODEFROMABOVE%3E%3D7%2C%22Approved%22%2C%22Pending%22)%2C%20so%20the%20full%20thing%20would%20look%20like%3A%3C%2FCODEFROMABOVE%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DIF(IF(%5Bcolumn1%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn2%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn3%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn4%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn5%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn6%5D%3D%22Approved%22%2C1%2C0)%2BIF(%5Bcolumn7%5D%3D%22Approved%22%2C1%2C0)%3D7%2C%22Approved%22%2C%22Pending%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861469%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20nested%20IF%2FAND%20statement%20for%20a%20Calculated%20Column%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861469%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F189854%22%20target%3D%22_blank%22%3E%40Robin%20Nilsson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20million%2C%20saved%20me%20some%20headache.%20Had%20to%20tweak%20it%20a%20little%20but%20works%20like%20a%20charm.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I'm having issues getting a calculated column to play nice. Basically in a list I have 7 "Approval" columns that are populated via a Approval Flows. I'm wanting this calculated column to update to "Approved" once the other 7 columns all switch to "Approve". 

 

I either get a syntax message when I try to save the formula. Or the few iterations when it does accept it, it isn't behaving as intended. I'm sure I'm missing something obvious, but banging my head on the desk at this point. 

 

Please help!

 

=IF([Column1]=Approve,AND([Column2]=Approve,AND([Column3]=Approve,AND([Column4]=Approve,AND([Column5]=Approve,AND([Column6]=Approve,AND([Column7]=Approve, "Approved","Pending")))))))

2 Replies
Best Response confirmed by Jon Gertken (Occasional Contributor)
Solution

@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")

 

 

@Robin Nilsson 

 

Thanks a million, saved me some headache. Had to tweak it a little but works like a charm.