Formula: 5 Checkboxes in Nested IF statement

This discussion was created from comments split from:Check Box & IF Statements.

Answers

  • Gunn_Jack
    Gunn_Jack ✭✭✭✭

    Hi all,

    I know this is a bit of an old post but i am having a similar problem and was hoping someone could help.

    I have 5 check boxes and based on these being ticked or unticked i want to display something in another cell.

    It is essentially a decision tree that simply i want to work as follows:

    If Group 2 is not ticked (or nothing ticked) = Group 1

    If Group 2 is ticked but 3, 4, 5 & Close are not = Group 2

    If Groups 2 & 3 are ticked but 4, 5 & Close are not = Group 3

    If Groups 2, 3 & 4 are ticked but 5 and close are not = Group 4

    If Groups 2, 3, 4 & 5 are ticked but close is not = Group 5

    If Group 2, 3, 4, 5 & Close are ticked (all are ticked) = Close

    Any ways of doing this simpler than building in every possible scenario via nested IFs? Also i couldnt quite get my head around the above. It is a linear structure in that 3 will not be ticked before 2 for example which i know avoids me having to do every combination.

    Any help is much appreciated.

    Thanks,

    Jack

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    @Gunn_JackI recently provided a solution to a question very similar to this. I will see if I can find it.

    thinkspi.com

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    edited 05/13/20

    @Gunn_JackIt looks like it was on another one of your posts...


    Work backwards with your IF statements. Nested IFs stop on the first true value, so if it makes it to the next one, then the previous IF(s) MUST be false.<\/p>

    =IF(Close@row = 1, "Close", <\/strong><\/p>

    Starting with this means that everything that follows automatically assumes that Close@row is NOT checked.<\/p>

    =IF(Close@row = 1, "Close", IF([Group 5]@row = 1, "Group 5", <\/strong><\/p>

    Anything coming after this portion automatically assumes that Close@row and [Group 5]@row are both unchecked. So we continue with this logic that "if it has made it this far then everything before it must be false" and work (almost) the rest of your requirements in using the same logic.<\/p>

    =IF(Close@row = 1, "Close", IF([Group 5]@row = 1, "Group 5", IF([Group 4]@row = 1, "Group 4", IF([Group 3]@row = 1, "Group 3", IF([Group 2]@row = 1, "Group 2", <\/strong><\/p>

    Now that we only have one option left (because to get this far everything prior must be false which means all of those boxes are unchecked), we can just use the "if false" portion of the final IF statement to say that if everything prior is false, "Group 1". Then we close out all of the IF statements all at once and your formula is complete.<\/p>

    =IF(Close@row = 1, "Close", IF([Group 5]@row = 1, "Group 5", IF([Group 4]@row = 1, "Group 4", IF([Group 3]@row = 1, "Group 3", IF([Group 2]@row = 1, "Group 2", "Group 1")))))<\/strong><\/p>","bodyRaw":"[{\"insert\":\"Work backwards with your IF statements. Nested IFs stop on the first true value, so if it makes it to the next one, then the previous IF(s) MUST be false.\\n\\n=\"},{\"attributes\":{\"bold\":true},\"insert\":\"IF(Close@row = 1, \\\"Close\\\", \"},{\"insert\":\"\\nStarting with this means that everything that follows automatically assumes that Close@row is NOT checked.\\n\\n=IF(Close@row = 1, \\\"Close\\\", \"},{\"attributes\":{\"bold\":true},\"insert\":\"IF([Group 5]@row = 1, \\\"Group 5\\\", \"},{\"insert\":\"\\nAnything coming after this portion automatically assumes that Close@row and [Group 5]@row are both unchecked. So we continue with this logic that \\\"if it has made it this far then everything before it must be false\\\" and work (almost) the rest of your requirements in using the same logic.\\n\\n=IF(Close@row = 1, \\\"Close\\\", IF([Group 5]@row = 1, \\\"Group 5\\\", \"},{\"attributes\":{\"bold\":true},\"insert\":\"IF([Group 4]@row = 1, \\\"Group 4\\\", IF([Group 3]@row = 1, \\\"Group 3\\\", IF([Group 2]@row = 1, \\\"Group 2\\\", \"},{\"insert\":\"\\nNow that we only have one option left (because to get this far everything prior must be false which means all of those boxes are unchecked), we can just use the \\\"if false\\\" portion of the final IF statement to say that if everything prior is false, \\\"Group 1\\\". Then we close out all of the IF statements all at once and your formula is complete.\\n\\n=IF(Close@row = 1, \\\"Close\\\", IF([Group 5]@row = 1, \\\"Group 5\\\", IF([Group 4]@row = 1, \\\"Group 4\\\", IF([Group 3]@row = 1, \\\"Group 3\\\", IF([Group 2]@row = 1, \\\"Group 2\\\", \"},{\"attributes\":{\"bold\":true},\"insert\":\"\\\"Group 1\\\")))))\"},{\"insert\":\"\\n\"}]","format":"rich","dateInserted":"2020-05-12T13:06:04+00:00","insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-06-26T12:01:05+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"displayOptions":{"showUserLabel":false,"showCompactUserInfo":true,"showDiscussionLink":false,"showPostLink":false,"showCategoryLink":false,"renderFullContent":false,"expandByDefault":false},"url":"https:\/\/community.smartsheet.com\/discussion\/comment\/249788#Comment_249788","embedType":"quote"}"> https://community.smartsheet.com/discussion/comment/249788#Comment_249788


    Did that not work? Do you need something different?

    thinkspi.com

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
With the symbols you are using, the options would typically be represented by the text entries [Empty, Quarter, Half, Three Quarter, Full]. In this case, this should work:<\/p>

=IF(COUNTIF(CHILDREN([BallCell]@row), \"Empty\") = COUNT(CHILDREN([BallCell]@row)), \"Not Started\", IF(COUNTIF(CHILDREN([BallCell]@row), \"Full\") = COUNT(CHILDREN([BallCell]@row)), \"Completed\", \"In Progress\"))<\/p>

If you do have your sheet setup somehow so that the entries are respresented by [0, 0.25, 0.50, 0.75, 1], then this should work:<\/p>

=IF(COUNTIF(CHILDREN([BallCell]@row), < 0.25) = COUNT(CHILDREN([BallCell]@row)), \"Not Started\", IF(COUNTIF(CHILDREN([BallCell]@row), 1) = COUNT(CHILDREN([BallCell]@row)), \"Completed\", \"In Progress\"))<\/p>

In either case, you will need to substitute [BallCell] with the name of the column with your symbols. The column name is not visible in your screenshot.<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":106869,"type":"question","name":"Formula to Assign Symbol based on a cell's value","excerpt":"This is a complicated one that I once got to work with RGY balls, but cannot figure out how to apply this to the Pain scale emojis. What I am trying to do: (Using the pain scale symbols) Have symbols automatically changed based on the value in the corresponding cell. I am already using a formula to assign a value based on…","categoryID":322,"dateInserted":"2023-06-24T20:02:20+00:00","dateUpdated":null,"dateLastComment":"2023-06-25T22:29:54+00:00","insertUserID":158092,"insertUser":{"userID":158092,"name":"MeganJF","url":"https:\/\/community.smartsheet.com\/profile\/MeganJF","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!DgFow9e-1vo!YfMmmJOUTjo!UDpVBcB6ikY","dateLastActive":"2023-06-25T17:43:33+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"updateUserID":null,"lastUserID":139601,"lastUser":{"userID":139601,"name":"jmyzk_cloudsmart_jp","title":"","url":"https:\/\/community.smartsheet.com\/profile\/jmyzk_cloudsmart_jp","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/ZBVD3K8PY0D5\/n7CZ1F4XWEM9Y.JPG","dateLastActive":"2023-06-26T04:50:32+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":5,"countViews":30,"score":null,"hot":3375372134,"url":"https:\/\/community.smartsheet.com\/discussion\/106869\/formula-to-assign-symbol-based-on-a-cells-value","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/106869\/formula-to-assign-symbol-based-on-a-cells-value","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":106869,"commentID":382193,"name":"Re: Formula to Assign Symbol based on a cell's value","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/382193#Comment_382193","dateInserted":"2023-06-25T22:29:54+00:00","insertUserID":139601,"insertUser":{"userID":139601,"name":"jmyzk_cloudsmart_jp","title":"","url":"https:\/\/community.smartsheet.com\/profile\/jmyzk_cloudsmart_jp","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/ZBVD3K8PY0D5\/n7CZ1F4XWEM9Y.JPG","dateLastActive":"2023-06-26T04:50:32+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-06-25T17:10:13+00:00","dateAnswered":"2023-06-25T03:32:30+00:00","acceptedAnswers":[{"commentID":382165,"body":"

Hi @MeganJF<\/p>

I guess you forget to use AND( ).<\/p>

For example, <\/p>