Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
pradeep92
Partner - Creator II
Partner - Creator II

use of hash() function

I know hash() function can be used to make fields of variable length to fixed length but when is the situation to use it ?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

  • AutoNumber() function just generates a sequential, integer number for each possible distinct value in the parameter, based on such value.
  • Hash*() functions do calculate a hash, and return that hash as a literal (string).
  • AutoNumberHash*() functions do both: first calculate the hash, then take that hash as a parameter and return an integer, sequential number based on it.

View solution in original post

5 Replies
Miguel_Angel_Baeyens

In the same situations than AutoNumber(), when you want to uniquely identify the same string across the application but using a fixed length string instead of a variable one (i.e.: street names or full names).

Also when you have a composite key (i.e. concatenating several values from different fields) you have created using several fields to uniquely identify a row in the data model by a smaller/fixed length value.

I never saw the case to use the Hash*() functions, but always the AutoNumber() function instead.

pradeep92
Partner - Creator II
Partner - Creator II
Author

Then as of my understanding, autonumber() and hash () function are the same in giving unique values but autonumber() return integer whereas hash() returns string.. Is this right ?

Miguel_Angel_Baeyens

  • AutoNumber() function just generates a sequential, integer number for each possible distinct value in the parameter, based on such value.
  • Hash*() functions do calculate a hash, and return that hash as a literal (string).
  • AutoNumberHash*() functions do both: first calculate the hash, then take that hash as a parameter and return an integer, sequential number based on it.
JaMajka1
Partner Ambassador
Partner Ambassador

Hi Pradeep,

actually hash() always returns the same output for the same input. It does not depend on your data in app and their order as it is in case of autonumber(). So you should use autonumber() only in one final app. If you need to generate the same key across applications (for example multi-layer generators) you should use hash().

BR,

Maria

pradeep92
Partner - Creator II
Partner - Creator II
Author

Okay great! thank you