Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Function to generate unique number/key in load script

I need to generate unique numbers/keys to replace a lengthy a concatenated key in the load script.

The unique number should be consistant and should persist reloads across different files. I'm not sure if autonumber() meets the requirement. I remember reading that it does not retain uniqueness. please advice.

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Use Hash128/160/256. These functions has a very low chance of colision

View solution in original post

2 Replies
Clever_Anjos
Employee
Employee

Use Hash128/160/256. These functions has a very low chance of colision

Anonymous
Not applicable
Author

I agree with Clever, to do what you're asking, the best option is HashXXX().  Unless you're dealing with rows in the billions, I'd recommend Hash128.  The only drawback that you'll find is that each unique instance requires 16 bytes (for Hash128, 160 is 20 bytes and 256 is 32 bytes per unique instance).  This shouldn't be an issue if you are storing tables into QVD, but I would suggest wrapping an AutoNumber(hash_field, 'key_name') around your hashed fields when loading into an application meant for user consumption.  It may slow down your reloads a little bit, but it will consume a lot less memory on load and should perform better.