Calculating a score based on multiple Choice fields
I have a form with 5 Choice fields, all have choices of Yes or No. I need to determine a score based on which ones are selected. For example, if Choice1 = No and Choice2 = Yes, then I want a score of 3. I attached a diagram of the choices and each score. I’d like to have just one score field that shows the appropriate score.
Is there a way I can make this work in the Nintex Form?
Page 1 / 1
Hi @jambou
Thanks for the diagram, it was very helpful
Initially I was rather skeptical to even attempt this because I was afraid of the cumbersome coding required. I was also afraid of conflicting rules where 2 conditions might exist simultaneously.
I wrote some Python code to verify the logic for all 32 permutations. I intentionally use IF (without the ELSE) to see whether any outcome would have more than 1 result.
## Jambou - 5 Choices Logic ## Set Choices Variables
for choice1 in False, True]: for choice2 in False, True]: for choice3 in False, True]: for choice4 in False, True]: for choice5 in False, True]: print( "C1:", int(choice1), end=' ') print("| C2:", int(choice2), end=' ') print("| C3:", int(choice3), end=' ') print("| C4:", int(choice4), end=' ') print("| C5:", int(choice5), end=' ')
if choice1 == False and choice2 == True: print("| 3", end=' ') if choice1 == False and choice2 == False and choice4 == False: print("| 1", end=' ') if choice1 == False and choice2 == False and choice4 == True: print("| 2", end=' ')
if choice1 == True and choice3 == False and choice5 == False: print("| 3", end=' ') if choice1 == True and choice3 == False and choice5 == True: print("| 2", end=' ') if choice1 == True and choice3 == True and choice5 == False: print("| 4", end=' ') if choice1 == True and choice3 == True and choice5 == True: print("| 5", end=' ')
print()
I was surprise by the results. Each permutation had exactly 1 outcome.