Skip to main content

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?

 

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.

PS D:\repos\starter70> & C:/Python310/python.exe d:/repos/starter70/00_Jambou.py
C1: 0 | C2: 0 | C3: 0 | C4: 0 | C5: 0 | 1
C1: 0 | C2: 0 | C3: 0 | C4: 0 | C5: 1 | 1
C1: 0 | C2: 0 | C3: 0 | C4: 1 | C5: 0 | 2
C1: 0 | C2: 0 | C3: 0 | C4: 1 | C5: 1 | 2
C1: 0 | C2: 0 | C3: 1 | C4: 0 | C5: 0 | 1
C1: 0 | C2: 0 | C3: 1 | C4: 0 | C5: 1 | 1
C1: 0 | C2: 0 | C3: 1 | C4: 1 | C5: 0 | 2
C1: 0 | C2: 0 | C3: 1 | C4: 1 | C5: 1 | 2
C1: 0 | C2: 1 | C3: 0 | C4: 0 | C5: 0 | 3
C1: 0 | C2: 1 | C3: 0 | C4: 0 | C5: 1 | 3
C1: 0 | C2: 1 | C3: 0 | C4: 1 | C5: 0 | 3
C1: 0 | C2: 1 | C3: 0 | C4: 1 | C5: 1 | 3
C1: 0 | C2: 1 | C3: 1 | C4: 0 | C5: 0 | 3
C1: 0 | C2: 1 | C3: 1 | C4: 0 | C5: 1 | 3
C1: 0 | C2: 1 | C3: 1 | C4: 1 | C5: 0 | 3
C1: 0 | C2: 1 | C3: 1 | C4: 1 | C5: 1 | 3
C1: 1 | C2: 0 | C3: 0 | C4: 0 | C5: 0 | 3
C1: 1 | C2: 0 | C3: 0 | C4: 0 | C5: 1 | 2
C1: 1 | C2: 0 | C3: 0 | C4: 1 | C5: 0 | 3
C1: 1 | C2: 0 | C3: 0 | C4: 1 | C5: 1 | 2
C1: 1 | C2: 0 | C3: 1 | C4: 0 | C5: 0 | 4
C1: 1 | C2: 0 | C3: 1 | C4: 0 | C5: 1 | 5
C1: 1 | C2: 0 | C3: 1 | C4: 1 | C5: 0 | 4
C1: 1 | C2: 0 | C3: 1 | C4: 1 | C5: 1 | 5
C1: 1 | C2: 1 | C3: 0 | C4: 0 | C5: 0 | 3
C1: 1 | C2: 1 | C3: 0 | C4: 0 | C5: 1 | 2
C1: 1 | C2: 1 | C3: 0 | C4: 1 | C5: 0 | 3
C1: 1 | C2: 1 | C3: 0 | C4: 1 | C5: 1 | 2
C1: 1 | C2: 1 | C3: 1 | C4: 0 | C5: 0 | 4
C1: 1 | C2: 1 | C3: 1 | C4: 0 | C5: 1 | 5
C1: 1 | C2: 1 | C3: 1 | C4: 1 | C5: 0 | 4
C1: 1 | C2: 1 | C3: 1 | C4: 1 | C5: 1 | 5

I figure that you would need just seven conditions to get the score.

if( condition, score, zero)

Example 

if( choice1 == "No" && choice2 == "Yes", 3, 0)

The seven conditions. If the condition is TRUE then a score is assigned otherwise it gets 0 (zero).

So all we need to do it to stack all the seven condition.

if( condition1, score1, zero) +
if( condition2, score2, zero) +
if( condition3, score3, zero) +
if( condition4, score4, zero) +
if( condition5, score5, zero) +
if( condition6, score6, zero) +
if( condition7, score7, zero)

The code. Let me know if you need further clarification.

Hope that my explanation is clear. 

 


Reply