Excluding choice from count-selected

Hi you guys,

This question is so easy, i feel a little stupid..but.... I want to exclude counting a choice in a count-selected question type. This is what I have

cond(question10 = 'no_debt', 5, count-selected(question10) = 1, 3, count-selected(question) = 2 < 3, 2, count-selected(question10) >= 4, 1, "0")

but if question 10 has selected option "6" it should be excluded from the total count.

So I need to do something like: "the above" and not(question10 = false, total-count = (count-selected(question10)-1)

but that's not real xpath, what I have is screenshot below. How can I clean this up? When I run the code it evaluates to TRUE :woman_shrugging:

Thanks

Hi Shawn,

I think what you wrote is what I would have done. IE:

replace every instance of

count-selected(question10)

with

if(selected(question10, '6'), count-selected(question10) - 1, count-selected(question10))

Hi Clayton thanks for responding.

I don't quite understand this is what I have now:

if(selected(question10, choice6), count-selected(question10) - 1, count-selected(question10))

and cond(question10 = 'no_debt', 5, count-selected(question10) = 1, 3, count-selected(question10) = 2 < 3, 2, count-selected(question10) >= 4, 1, "0")

replace the if statement or the cond?

Thanks again

You'd have to make the replacement Clayton described every time you want to know the number selected that aren't choice 6. You could also use an intermediate variable to make the logic a little easier to follow.

That is, make a hidden value called total_count, and set that to

if(selected(question10, '6'), count-selected(question10) - 1, count-selected(question10))

Then rather than writing count-selected a bunch of times, reference that hidden value:

cond(
  question10 = 'no_debt', 5,
  #form/total_count = 1, 3,
  #form/total_count < 3, 2,
  #form/total_count >= 4, 1,
  0
)

I also see in your screenshot and original question:

count-selected(question) = 2 < 3

This looks like a typo.

Thank you. I followed your instructions and they were accepted. Now I will test it. Thanks again :slightly_smiling_face:

As for the 'typo' I believed I was inputting the intruction to say, count-selected(question)= 2 to 3 items, then apply value of 4.

But I see that your way makes sense