Select to view content in your preferred language

'when' statement calculation help

146
1
Jump to solution
Friday
amanda_stanko
Esri Contributor

I'm struggling with this 'when' statement in Survey123 XLSForm.

The form averages input from the questions to get a final score. The part I'm struggling with is converting the score to a letter grade. 

I've tried many derivatives of this, or with 'if' statements. It all keeps failing. 

when(${gradeSum} < 1, 'F', (${gradeSum}>= 1 and ${gradeSum} < 2), 'D', (${gradeSum}>= 2 and ${gradeSum} < 3), 'C', (${gradeSum}>= 3 and ${gradeSum} < 4), 'B','A')

I've also tried this, and it doesn't work.

if($gradeSum} < 1, 'F',
if((${gradeSum} >= 1) and (${gradeSum} < 2 ), 'D',
if((${gradeSum} >= 2) and (${gradeSum} < 3), 'C',
if((${gradeSum} >= 3) and (${gradeSum} < 4), 'B',
'A'
)
)
)
)

 

XLSForm attached. 

Thanks in advance for your help!

0 Kudos
1 Solution

Accepted Solutions
amanda_stanko
Esri Contributor

I got it to work! 
I realized I was missing a bracket. 😣

if(${gradeSum} < 1, 'F',
if((${gradeSum} >= 1) and (${gradeSum} < 2 ), 'D',
if((${gradeSum} >= 2) and (${gradeSum} < 3), 'C',
if((${gradeSum} >= 3) and (${gradeSum} < 4), 'B',
'A'
)
)
)
)

View solution in original post

0 Kudos
1 Reply
amanda_stanko
Esri Contributor

I got it to work! 
I realized I was missing a bracket. 😣

if(${gradeSum} < 1, 'F',
if((${gradeSum} >= 1) and (${gradeSum} < 2 ), 'D',
if((${gradeSum} >= 2) and (${gradeSum} < 3), 'C',
if((${gradeSum} >= 3) and (${gradeSum} < 4), 'B',
'A'
)
)
)
)

0 Kudos