Count Matrix text entry with data | XM Community
Skip to main content
Solved

Count Matrix text entry with data

  • 2 October 2023
  • 2 replies
  • 29 views

Hello and thank you in advance,

I have a Matrix text entry question. The user does not have to provide data in all 7 rows. I’d like to get a count of how many times data is provided in the “Subject”, "ImportId":"QID38_1_1"} {"ImportId":"QID38_2_1"}{"ImportId":"QID38_3_1"} {"ImportId":"QID38_4_1"} {"ImportId":"QID38_5_1"} {"ImportId":"QID38_6_1"} {"ImportId":"QID38_7_1"}.

I created an embedded field, Embedded_Course_Count and with the help of ChatGPT I tried a couple of javascripts but I get no output or 7. 

Is what I’m attempting possible? Is anyone able to help me with a javascript or another possible solution?

Thank you, Noreen

 

2 replies

Userlevel 7
Badge +27
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var count = 0;
jQuery("#"+this.questionId+" .c4 [type=text]").each( if(this.value.length>0) count++; });
Qualtrics.SurveyEngine.setEmbeddedData("Embedded_Course_Count",count);
});

 

Badge +6

@TomG Thank you so much. Your help is greatly appreciated. 

Leave a Reply