Comparing the responses to two questions | XM Community
Skip to main content
Solved

Comparing the responses to two questions

  • May 24, 2024
  • 2 replies
  • 155 views

Forum|alt.badge.img

I have a simple need - to compare the values entered in to two text entries questions (validation numbers 0-100, no decimals) to make sure that one is less than or equal to the other, ie Age >= AgeDiagnosis. I’ve tried setting Enbedded Data Variables (Age, AgeDiagnosis), but cannot use Enbedded Data in custom validation of these questions. Is there another another easy way of comparing the response to these two questions, and if not valis, prompting the user to re-enter the second age?

Thank you!

Best answer by omkarkewat

Hi @MirandaSC Make sure both these questions are on separate pages and then apply the below custom validation.

Q1 Age - Custom validation - “entered value matches regex ^(100|[0-9]{1,2})$

 

Q2 AgeDiagnosis - Custom validation - “entered value matches regex ^(100|[0-9]{1,2})$ AND it is less than ${q://QID1/ChoiceTextEntryValue} 

Here QID1 is the age question.

NOTE: Replace the above pipe text value with your own age question ID.

 

2 replies

Forum|alt.badge.img+21
  • QPN Level 5 ●●●●●
  • 306 replies
  • Answer
  • May 24, 2024

Hi @MirandaSC Make sure both these questions are on separate pages and then apply the below custom validation.

Q1 Age - Custom validation - “entered value matches regex ^(100|[0-9]{1,2})$

 

Q2 AgeDiagnosis - Custom validation - “entered value matches regex ^(100|[0-9]{1,2})$ AND it is less than ${q://QID1/ChoiceTextEntryValue} 

Here QID1 is the age question.

NOTE: Replace the above pipe text value with your own age question ID.

 


Forum|alt.badge.img
  • Author
  • 1 reply
  • May 26, 2024

Thank you very much for your help. It worked perfectly! Just need to figure out what “^(100|[0-9]{1,2})$” means!