More details needed to generate random number with no repeats. Any solution yet? | XM Community
Skip to main content
Hi all - Thanks for reading!



I know this question has been asked several times already (e.g., https://www.qualtrics.com/community/discussion/85/i-want-to-randomly-assign-a-4-digit-id-to-every-respondent-with-no-repeats), but thought I'd check in again about this to see if someone could provide a more specific answer, since this _has_ to be a need that many people have.



I want to assign a random 6-digit number as a respondent enters a survey, but it's _essential_ that there be no repeats. I know Qualtrics' random number generator can do this, but can't guarantee it won't repeat. So, several others have suggested setting up a web service or library to do this. But can anyone provide more details about exactly how to do this?



There has to be a solution out there, and I think it'd be really helpful to a lot of people to post it here.
If you are distributing via contact list , let add one extra column say number, for each contact set any random number with excel random number generator.



Create embedded variable in survey say randnum and set it like 100000+number piped from your contact list.
We are not distributing via contact list. This would be to assign a random, unique ID number to respondents who arrive at the survey via a URL in advertisements, etc.
Just checking, cant we use "ResponseID" embedded data which always unique for each survey record.

However, this won't be 6 digit number... ResponseID is alphanumeric and always unique for each record in a survey.
Ah, that may be a good solution for many, if it's indeed unique. We could really use a 6-digit integer, though.
@twray,



You need to keep track of which numbers have been used. It would be best to use a web service for that. For example, you could:

1. Set up a one field database table with the numbers 100000 through 999999 as records.

2. Have your web service script grab a random record, delete the record it just grabbed, and output the number it grabbed in a json string.

Leave a Reply