More details needed to generate random number with no repeats. Any solution yet? | XM Community
Solved

More details needed to generate random number with no repeats. Any solution yet?

  • 30 August 2018
  • 5 replies
  • 339 views

Badge +1
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.
icon

Best answer by MohammedAli_Rajapkar 30 August 2018, 18:00

View original

5 replies

Userlevel 7
Badge +33
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.
Badge +1
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.
Userlevel 7
Badge +20
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.
Badge +1
Ah, that may be a good solution for many, if it's indeed unique. We could really use a 6-digit integer, though.
Userlevel 7
Badge +27
@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