Please Help Urgent Kobo Work Project

hello please help :frowning:
I have to put scores for my answers and I’m getting errors! I have a question about age as the following:

  1. 50+
  2. 18 - 24
  3. 25 -49
    and each option of these should have a score. option 1 should have a zero score, option 2 should have a 2 score and option 3 should have a 4 score.
    I am not able to configure the if statements and so on! also I started this project freshly on Kobo toolbox meaning that I do not have it on Excel.
    I have been trying several formulas including: if(selected(${age},β€˜0’),β€˜0’,’’),if(selected(${age},β€˜2’),β€˜2’,’’),if(selected(${age},β€˜4’),β€˜4’,’’))

but it is not working!
Can anyone please help?

Welcome @basselalkan,
You need to keep to the syntax of a cascading if.
if( selected(${age},β€˜0’), β€˜0’ if( selected(${age},β€˜2’), β€˜2’, if( selected(${age},β€˜4’), β€˜4’, ’’ ) ) ).
A following if is replacing an else part.

Or - as this seems a select_one - yo don’t need selected and could use if( ${age} = β€˜0’, β€˜0’, if…

Why do you create an extra score, if the values are the same? Or did you put the wrong figures in your example? Different to your text.

If the mapping is such simple, you could just adapt the names/code of the age groups.
Or it could be score =
string( number(coalesce(${age}), β€˜0’)) + 1 )

Maybe you can provide a table how you want to map between age and score.

1 Like