Unique number

Hola comunidad,

Necesito crear un código numérico único de 3 dígitos y que este número se resetee cada día.

¿Alguna idea de como puedo hacer esto?

Gracias

Saludos 

0 10 289
10 REPLIES 10

RIGHT(UNIQUEID(), 3)

"código numérico único de 3 dígitos"

It sounds you are looking for numeric results. If so,  you could evaluate RANDBETWEEN()

RANDBETWEEN(100, 999)

https://help.appsheet.com/en/articles/2357303-randbetween

However RANDBETWEEN() has much higher repeat probability as compared to UNIQUEID() because RANDBETWEEN() is just numeric (0-9) while UNIQUEID() is alphanumeric( A-Z, 0-9).

So a three digit numeric number will have a repeat probablity of around 1/(999-99) that is around 0.11 percent

On the other hand, a 3 character UNIQUEID() is much better as it will have repeat probability of just 1/ (36*36*36) or just 0.0021%

So please consider suggestion by @Joseph_Seddik for better non repeat probability.

@Suvrutt_Gurjar 

Your answer with such detailed explanation and probability calculation is actually (much*much*much) better 🙂 

Also, seeing 36, I didn’t know that all letters are included in UNIQUEID() generation; I thought only hex digits are used, so thank you!!

Thank you both guys. @Suvrutt_Gurjar @Joseph_Seddik  I only doubt remains. So with the following formula "RIGHT(UNIQUEID(), 3)". Is not possible to get only numbers WITHOUT letters?

And second question: What can I do so that the automatically generated s numbers can be reset every 12 hours?

Thanks again

If you wish only numbers, you will need to use RANDBETWEEN() for only numeric values.

Your second query is not clear. Could you please elaborate.

Thanks.

About the second query. This is the scenario:

I have created an application for sending packages. Every time a new shipment is created, it must have a consecutive and unique ID. But that ID needs to be reset every 24 hours.

For example, if 10,000 shipments were created today (using consecutive numbers from 01 to 10,000) from the next day it starts again from 01

I hope I have explained myself

Hi @Joseph_Seddik ,

You brought up a very interesting point on UNIQUEID() having only six hex letters. I tried to dig more and my observations are below

1. All of my apps that I took a look at have UNIQUEID() restricted to six hex letters in them. 

2. However following sample app that I use often as a base test app has letters other than hex letters in UNIQEID() based key columns in Orders and Order details tables. Not sure whether those IDs were manually added by the app creator or the UNIQUEID() generation algorithm has changed since then.

https://www.appsheet.com/Template/AppDef?appName=OrderCaptureHow-to-71626&appId=OrderCaptureHow-to-7...

3. The help documentation on UNIQEID() just mentions letters and numbers, not specifically about Hex letters.

https://help.appsheet.com/en/articles/2357317-uniqueid

https://help.appsheet.com/en/articles/1127188-text-expressions

Suvrutt_Gurjar_0-1645248495197.pngSuvrutt_Gurjar_1-1645248577056.png

 

May we request @Steve for his insights.

Thank you @Suvrutt_Gurjar. I reviewed my tables and it seems that only hex digits are used. 

For this kind of requirement, I think more details about how your data is set up and how the the daily shipments are recorded etc. will be required. Also this could be a substantial functionality and may need a comprehensive solution which could be outside the way typically community works- helping on a specific query ( Your first query on UNIQEID() for example)

Anyway based on your details provided

1) If it is a multi user environment , generating serial numbers is not a great idea in AppSheet. Please take a look at the following tip from @Steve 

https://www.googlecloudcommunity.com/gc/Tips-Tricks/Serial-Numbers-If-You-Must/m-p/286300

 

2) About starting them with a fresh series every day, as mentioned it will depend on your data structure and in general may not be very straight forward to achieve.

OK @Suvrutt_Gurjar I will check the url from Steve. 

Actually, the main idea is that consecutive numbers can be generated starting from number 1 until the end of a working day. And the next day start again at 1. That´s pretty much it

I was thinking in use IF or something like to reset the used consecutives

Top Labels in this Space