Custom validation based on answer to previous question | XM Community
Skip to main content

I have two questions and need to validate the answer to second question based on first.

The questions are:

  1. Which of the two do you think you spend more on? (Multiple choice)

  2. Flipkart

  3. Amazon

  4. Equally both

  5. Divide 100 points such that your allocation reflects the relative expenditure across two platforms. (Constant sum)

  6. Flipkart ___________

  7. Amazon ___________

  8. Total ___________


I want to put two validations for answer to the second question:
  • The allocation should be 50-50 in case option (c) is selected for Q1, otherwise it should be greater than 50 for option selected in Q1.

  • The sum of allocation to Flipkart and Amazon should add up to 100. (this is easy to be done alone, but I don't know how to do it along with first validation)

Please help me with the same.

rochak_khandelwal
A simple solution could be to skip the second question for those who select equally both and within survey flow create a branch logic (if equally both is selectrd) and include embedded data hardcode the value 50 for them for each option. For the second condition you already know how to include that validation, just push the same in similar embedded data and you will have your values at one place.
But if you want to show the question to both you will not be able to do the if condition here, you will have to create 2 similar questions and show either of them based on their previous questions response.
Hope it helps!


https://community.qualtrics.com/XMcommunity/discussion/comment/52157#Comment_52157Hey Deepak, thanks for your reply. However, I do want to put both the questions, otherwise I could have just eliminated the first question and used the second one only.


https://community.qualtrics.com/XMcommunity/discussion/comment/52160#Comment_52160I think you misinterpreted my solution you have to just skip for those who select equally both as you already know it will be 50-50. Rest can see it. Also, if you want to show to all you need to create two questions or custom code the custom validation here if needed in just one question.
Hope it helps!


https://community.qualtrics.com/XMcommunity/discussion/comment/52162#Comment_52162I was not able to understand part of your first reply. I could understand the 50-50 part and skipping the second question for those fellows. But, How should I ensure first validation for remaining set of people.
I hope I am able to make myself understand.


rochak_khandelwal
The first validation isif I am not wrong it needs to be 50-50 if equally both is selected and if other is selected you need one greater than other. You can apply it like this, if you are skipping for equally both:
image.pngHope it helps!


Good morning from a cloudy Sweden!
I dont really see why you even need the first question. The data you get from question two answers question one automatically.
Just my lousy two cents 🙂
-Mattias


Hi rochak_khandelwal,
I'll advice you to create one extra question (question 3rd) which will be a copy of your 2nd question (in total 3 questions) and add a display logic saying show question 3rd if 'equally both' is selected in 1st question. And then add a custom validation to the same saying 'Validation will pass only if 50 and 50 is the input in Amazon and Flipkart respectively', this will automatically ensure that the total is 100 so no need to worry about how to insert two validations in a single question.
And add a simple display logic in your 2nd conventional question saying show if 'Amazon' or 'Flipkart' is selected in question 1st. (Don't forget to add the validation saying 'total must be 100', which you must be obviously knowing how to apply it.)
I'm also attaching a screenshot for a better understanding.
image.pngValidation for 3rd question:
image.png

Hope it helps.
Happy New Year!😊


rochak_khandelwal,
You can use custom validation on the constant sum question like this:
image.pngThe piped text, in order, is as follows:

  1. $e{ 100 - q://QID301/ChoiceNumericEntryValue/2 }
    (i.e., 100 - Amazon constant sum value)

  2. ${q://QID301/ChoiceNumericEntryValue/2}
    (i.e., Amazon constant sum value)

  3. ${q://QID301/ChoiceNumericEntryValue/1}
    (i.e., Flipkart constant sum value)

No other questions, skip/display logic, or survey flow logic needed.


Leave a Reply