Select to view content in your preferred language

How can I set up a unique random number in Survey123?

3242
6
02-27-2019 10:37 AM
KenMorefield
Occasional Contributor

I want people to submit a survey, which has a unique, random number that is hidden to the end user.  This number will be used as part of a "lottery" drawing, once all surveys have been submitted.  The unique, random number will be sorted low to high, and the lowest 10 numbers will be winners.  I envision my staff running a manual sort of the number in a web map, and then manually keying in a Selected = YES to the lowest 10 numbers.  Any ideas how to do this?  I know Global ID's are unique, but not necessarily random.  I'm trying to make is as simple as possible for non-technical staff to run.  I'd like to avoid ArcMap and ArcPro if possible - and do everything in ArcGIS Online, Survey123, web maps, etc.

0 Kudos
6 Replies
JoeBorgione
MVP Emeritus

How much more random can a Global ID get?  You could look at a GUID field.  I've used the procedure described here How To: Calculate unique identifier values similar to Global IDs but I couldn't tell you how to do that  in Survey 123.

That should just about do it....
0 Kudos
KenMorefield
Occasional Contributor

Hi Joe - I guess I just don't really know how random a Global ID is.  I know they are unique - but if you use that number and sort ascending or descending, assuming it to be random - Is it truly random?  Would a person receive preferential ranking if they submitted their survey first, or last?  I don't really know.  It seems that I have read that they are not random...

0 Kudos
JoeBorgione
MVP Emeritus

Here is a screen shot of 30 out of 3341 GlobalIDs sorted in ascending order:

From What is random numbers? - Definition from WhatIs.com :

Random numbers are numbers that occur in a sequence such that two conditions are met: (1) the values are uniformly distributed over a defined interval or set, and (2) it is impossible to predict future values based on past or present ones. Random numbers are important in statistical analysis and probability theory

Do they meet the two criteria?

That should just about do it....
0 Kudos
NickDierks1
Occasional Contributor II

I don't believe there's any way to guarantee that it's unique (edit: without using a GlobalID, I mean).

How many responses do you expect to have? You could try using random() in a calculation. This returns a value between 0 (inclusive) and 1 (exclusive). For a more "friendly" number you can multiply it by a value and round it off, for example round(random()*100000,0) results in a range of 0 to 100,000. You could then use another random() function in a second question to be used as a tie-breaker, because hopefully no one will end up with the same random lotto number and identical tie-breaker numbers, but who knows? Or maybe even use a timestamp as a tie-breaker?

0 Kudos
KenMorefield
Occasional Contributor

Thanks for chiming in Nick.  Realistically, there will probably be fewer than 100 survey entries.  So maybe I'm overthinking the chances of having to random numbers come out the same.  Using your rounding and/or a tiebreaker field would probably insure that I never have a problem (with so few entries).  I'll try a few approaches and see what I find.

0 Kudos
by Anonymous User
Not applicable
0 Kudos