# Constraint, fields must add up to 10, conditional questions

Hi all, would greatly appreciate any help!

1. What is the problem? Be very detailed.
The problem is that I'm trying to add a constraint so that the answers on that page must add up to 10. But with two caveats: for various reasons, i) I must use select_one, not integer for those questions, and ii) those questions have relevant clause conditional on an earlier question. I know how to make it work if it weren't for those relevant clause, which seem to interfere with the constraint calculation. As a result, I cannot get the constraint to work.

The problematic cells are highlighted here: GMLGhana_test.xlsx (50.5 KB)

2. What app or server are you using and on what device and operating system? Include version numbers.
Using XLS form, ODK collect v1.27.2

Thanks so much!!
Xue

Hi @Xue
welcome to the forum! Please introduce yourself here!
the way you calculate percents is wrong. you use number function which is for calculating dates. You need to use something ugly like:

``````if(selected(\${d1},'1'),10,if(selected(\${d1},'2'),20,if(selected(\${d1},'3'),30,if(selected(\${d1},'4'),40,if(selected(\${d1},'5'),50,if(selected(\${d1},'6'),60,if(selected(\${d1},'7'),70,if(selected(\${d1},'8'),80,if(selected(\${d1},'9'),90,if(selected(\${d1},'10'),100,0))))))))))
``````

I would also rather create one final note that would check the sum and then add one constraint there.