Remove duplicate text entries to display only one | XM Community
Question

Remove duplicate text entries to display only one

  • 14 January 2021
  • 2 replies
  • 123 views

Hi! Someone else already asked this question, but they never posted what the solution to the problem was, so I figured I'd ask again. I have a several Text Entry questions with more then one text field. Each question asks about the same topic but in a different situation, so survey respondents could enter the same answer into the Text Entry fields across multiple questions.
b3kyfbb27prx.png
Using Display Logic, the answers to these many questions are then piped into a single Pick, Group & Rank question for survey respondents to do just that.
For this to work properly for the outputs I require, I need any duplicate responses piped from all of the Text Entry questions to ONLY be presented as a SINGLE option in the Pick, Group & Rank question. As an example:
If a survey respondent were to enter "IBM" 4 times into different Text Entry questions, I currently receive 4 separate "IBM" options listed in the Pick, Group & Rank question:
qw8f5i0ynwyb.png
However, the desired output for the options in the Pick, Group & Rank question from the 4 entered "IBM" responses is just a single "IBM" option:
seqxni9rn011.png
I've attempted several Display Logic solutions (primarily using "AND" and "Is Not Equal To" the piped text from the prior Text Entry questions) for the individual options in the Pick, Group & Rank question, but have only succeeded in being stuck with the original state showing multiple of the same Text Entry response or showing no duplicate responses. I've tried using some basic Javascript to create an array with the answers then remove duplicates, but I can't seem to figure it out.
Do any of you know how to do this?


2 replies

Badge

Did you ever get a response? I have the exact same scenario and would love help.

Thanks!

Badge

ahmedA has a great solution to this problem! You should contact him if you need more help. He is a Qualtrics Wizard and helped me find this post again to try to share with the community.
If you want to venture out on your own, you might benefit from reading about what I did. Be warned, I don't know JavaScript but the following code allowed me to filter out unique names. I pieced together code from multiple sources and edited. I can't recall where I got the code and which pieces I took from which sources so I'm not able to cite other people here. For those new to Javascript it helped me to go here https://www.w3schools.com/js/tryit.asp?filename=tryjs_editor and to try out my code to troubleshoot before incorporating it into Qualtrics.
The code below grabs the text entered into one of the text boxes within a matrix question (in this case question QID486). For personal reasons, I then split the first and last name and concatenate them again into a first name and first initial of the last name whenever the text box was not empty. Those names are labeled "new_name#" = name. The magic of getting a unique list happens (in the screenshot) after "var array =[{"name":"new_name"},...];". Make sure to add the Javascript code below the "Qualtrics.SurveyEngine.addOnload(function()". And also make sure that you've set up the embedded data field "unique_local_names".
Capture.JPGAfterwards, you'll end up with a list of unique names separated by a comma. To use this list of unique names you then need to split the names up again and put them onto distinct embedded fields. In the code below I'm calling each of the names, "NominatedPeers" so in my embedded data you'd see "NominatedPeers1", "NominatedPeers2" and so on. You'd need to change the beginning var str embedded data field from Nominated peers to "unique_local_names" or whatever you ended up naming your unique list.
new.JPGYou now have the unique names in embedded data fields and you can pipe them into your survey into whatever question you'd like. In this case, you'd likely use branch logic or display logic to say that if an embedded data field is not empty they should be displayed in a rank order question.
Lastly, make sure that you place the JavaScript code in the right spot. For example, if you place these on or before the questions where you collected the text, they won't work.
Good luck! If you run into problems, again ahmedA is a great resource.

Leave a Reply