Constant Sum Must Total but not mandatory? | XM Community
Skip to main content
Solved

Constant Sum Must Total but not mandatory?

  • September 28, 2018
  • 6 replies
  • 111 views

Forum|alt.badge.img+10
  • Level 2 ●●
  • 34 replies
Is it possible to custom code a constant sum question so that the responses must total 100%, but it could also be left blank (all rows at 0) as well?

Best answer by Anonymous

Hello @Nadaly The solution is using custom validation. In the Constant Sum question add following custom validation ! In the first condition paste the following math operation `$e{ 100 - ( q://QID24/ChoiceNumericEntryValue/2 + q://QID24/ChoiceNumericEntryValue/3 ) }` In second condition(after OR) paste the following math operation ` $e{ 0 - ( q://QID24/ChoiceNumericEntryValue/2 + q://QID24/ChoiceNumericEntryValue/3 ) }` Also, Select "Enforce Range" with 0 as min value, so that the user cannot answer negative values Explanation: Suppose you have three rows(A, B, C) then either A= 100-(B+C) OR A=0- (B+C)
View original

6 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 28, 2018
Yes, sum the total anytime one of the fields changes, then enable the next button if it totals 0 or 100, otherwise disable the next button.

  • 0 replies
  • Answer
  • September 28, 2018
Hello @Nadaly The solution is using custom validation. In the Constant Sum question add following custom validation ! In the first condition paste the following math operation `$e{ 100 - ( q://QID24/ChoiceNumericEntryValue/2 + q://QID24/ChoiceNumericEntryValue/3 ) }` In second condition(after OR) paste the following math operation ` $e{ 0 - ( q://QID24/ChoiceNumericEntryValue/2 + q://QID24/ChoiceNumericEntryValue/3 ) }` Also, Select "Enforce Range" with 0 as min value, so that the user cannot answer negative values Explanation: Suppose you have three rows(A, B, C) then either A= 100-(B+C) OR A=0- (B+C)

Forum|alt.badge.img+10
  • Author
  • Level 2 ●●
  • 34 replies
  • September 28, 2018
@Shashi Thanks. This makes sense. I got it to work using a 2-row question! But it doesn't on one that is 4 rows. Is this bad math? $e{ 100 - ( q://QID7/ChoiceNumericEntryValue/2 + q://QID7/ChoiceNumericEntryValue/3 + q://QID7/ChoiceNumericEntryValue/4) } $e{ 0 - ( q://QID7/ChoiceNumericEntryValue/2 + q://QID7/ChoiceNumericEntryValue/3 + q://QID7/ChoiceNumericEntryValue/4) }

  • 0 replies
  • September 28, 2018
> @Nadaly said: > @Shashi Thanks. This makes sense. I got it to work using a 2-row question! But it doesn't on one that is 4 rows. Is this bad math? > > $e{ 100 - ( q://QID7/ChoiceNumericEntryValue/2 + q://QID7/ChoiceNumericEntryValue/3 + q://QID7/ChoiceNumericEntryValue/4) } > > $e{ 0 - ( q://QID7/ChoiceNumericEntryValue/2 + q://QID7/ChoiceNumericEntryValue/3 + q://QID7/ChoiceNumericEntryValue/4) } There should be a space between 4 and ')'

Hi, I have exactly the same problem but for me the code provided above does not seem to work. I am using: $e{ 100 - ( q://QID206/ChoiceNumericEntryValue/2 + q://QID206/ChoiceNumericEntryValue/3 + q://QID206/ChoiceNumericEntryValue/4 + q://QID206/ChoiceNumericEntryValue/5 ) } and my question looks like this:!

Forum|alt.badge.img+10
  • Author
  • Level 2 ●●
  • 34 replies
  • December 12, 2018
@_Hannah1073 I tried your code on a slider question and it worked fine for me to prevent someone from moving forward unless the sum was 100. What is happening for you? Are respondents able to move forward with a sum>100?

Leave a Reply