Custom Validation for Matrix Constant Sum | XM Community
Skip to main content
Solved

Custom Validation for Matrix Constant Sum


Forum|alt.badge.img+3

Hello, 

 

I need validation so that the sum of the percentages is 100% or “Don’t Know” is selected. I don’t see an option for summing the percentages in custom validation, so I think I need custom JavaScript but I am not a coder! Could someone please assist? 

 

Thank you in advance! 

Caroline

Best answer by TomG

@Carolinedavies - You can sum the total with an math expression in your validation condition:

Category A = $e{ 100 - q://QIDx/ChoiceNumericEntryValue/2 - q://QIDx/ChoiceNumericEntryValue/3 - q://QIDx/ChoiceNumericEntryValue/4 - q://QIDx/ChoiceNumericEntryValue/5 }

OR

Don’t know is selected

View original

6 replies

Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1091 replies
  • October 24, 2023

Hi @Carolinedavies 

There’s must total option in the validation section. Hope this helps
 

 


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 6 replies
  • October 24, 2023

@dxconnamnguyen Yes, I tried that (sorry I should have mentioned this is my original post), but the problem is if you select “Don’t Know” the total still must be 100.  


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5923 replies
  • Answer
  • October 24, 2023

@Carolinedavies - You can sum the total with an math expression in your validation condition:

Category A = $e{ 100 - q://QIDx/ChoiceNumericEntryValue/2 - q://QIDx/ChoiceNumericEntryValue/3 - q://QIDx/ChoiceNumericEntryValue/4 - q://QIDx/ChoiceNumericEntryValue/5 }

OR

Don’t know is selected


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 6 replies
  • October 24, 2023

@TomG Thank you so so much!! This really saved us. 

I used Category A = $e{100 - ${q://QID1/ChoiceNumericEntryValue/2/1} - ${q://QID1/ChoiceNumericEntryValue/3/1} - ${q://QID1/ChoiceNumericEntryValue/4/1} -  ${q://QID1/ChoiceNumericEntryValue/5/1}} 

 

It worked perfectly! Thanks Again! 


Forum|alt.badge.img+1
  • Level 2 ●●
  • 9 replies
  • April 22, 2024

Hey @Carolinedavies ,

Can you tell me how you added the “Don’t know” button at the bottom?


Forum|alt.badge.img+2
  • Level 2 ●●
  • 10 replies
  • July 16, 2024

I want to set constant sum with Don’t know(exclusive) option. Here brands are coming from previous selection. Please help to set up.. @TomG 

 

Example-
Q4 is a multiselect question, where i select option A,B,C
 

 

 

Then next question shows like 

 

Now, i want to select either “Don’t know” or input values for A,B,C. The input value for A,B,C must be 100.
How can i validate Q2, as number of options based on previous question Q4.


Leave a Reply