Adding hidden values with conditions

Hi All,

I am attempting to average two hidden values while placing a condition on one to exclude if response is “0” , effectively just leaving the one hidden value. I know my Xpath isn’t the best so any ideas on what I can fix would be appreciated.

Here is what I have:

These are the instructions I am attempting to implement:

I think you want

if(domain_1b_score > 0, (domain_1b_score + domain_1a_score) div 2, domain_1a_score)

As written, this expression would always divide the first field by two.

I think what you want is closer to

if(1b > 0, (1a+1b) div 2, 1a)

-Clayton

Hey thanks I will try this

I will give it a shot :sweat_smile:

Hey you guys, theorectically, yeah, I agreed, tried both suggestions and did not receive an accurate output. It is just domain 1a that is returned.

Would it help if I don’t make the question optional? So then I can just do (1a +1b) div 2

from your screenshot above, it looks like domain_1a_score and domain_1b_score are both calculated values, not user input. I’d put each of those in a label to ensure they both evaluate to positive integers.

Thanks ethan, your label comment was useful as i figured out the suggested calculations were correct, but I needed to update the label!

You guys rock!!!

Issue Resolved, gold stars for everyone.