Constant Sum | Experience Community
Skip to main content

Constant Sum

  • Feb 13, 2023 10:01 PM UTC
  • 5 replies
  • 57 views

Forum|alt.badge.img

image.pngMy total must be between 0 and 100.
What code should I add?

5 replies

jmborzick
QPN Level 5 ●●●●●
Forum|alt.badge.img+41
  • QPN Level 5 ●●●●●
  • Feb 13, 2023 11:12 PM UTC

Forum|alt.badge.img

I appreciate the effort but I'm far from being a Java expert so I need a more specific explanation.
The code is great but it doesn't accomplish what I need as it has variables that I am unsure how to identify in my project. Thanks !


qualtrics_nerd
Level 5 ●●●●●
Forum|alt.badge.img+19
  • Level 5 ●●●●●
  • Feb 14, 2023 1:32 AM UTC

Hi know_nothing ,
You don't need to code anything.
You can use inbuilt feature of Qualtrics for it, known as "Range requirements" in validation section.
image.pngThere you can set any range value as per your requirement.
For checking total sum to be 100 you can put validation "must total" be 100.
image.pngimage.png
Hope it resolves your query😊!!!


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Feb 14, 2023 8:37 AM UTC

Range requirement applies to the individual inputs, not the total.
JavaScript isn't needed.
Use custom validation with an arithmetic expression. For example, if the QID of your constant sum question was QIDx and you had three rows (not including Total):
If Choice1 Is Less Than or Equal to $e{ 100 - q://QIDx/ChoiceNumericEntryValue/2 - q://QIDx/ChoiceNumericEntryValue/3 }


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Feb 14, 2023 8:37 AM UTC

Duplicate post deleted