Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

hash128() without knowing the number of fields

Hi all,

I am trying to apply hash128() function on loaded records but I don't really know the name of the loaded fields neither their number .

Besides , the number of the fields is variable .

I tried hash128(*)  but it doesn't work. Is there any possible way to solve this problem?

Thank you,

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can use system functions to query the name and number of fields in a table.

Iterate over the field names and create variable with a concatenated string of your field names, then expand the variable in your hash128() function as argument.

System functions (from the help).

NoOfFields([ 'TableName ' ])

Returns the number of fields in a previously loaded table.

Examples:

LET a = NoOfFields('tab1');

Load *, NoOfFields( ) from abc.csv;

FieldName(nr ,'TableName')

Returns the name of the field with the specified number within a previously loaded table.

If the function is used within a load statement, it must not reference the table currently being loaded.

Examples:

LET a = FieldName(4,'tab1');

T1:
Load a, b, c, d from abc.csv
T2:
Load FieldName (2, 'T1') Autogenerate 1;

View solution in original post

3 Replies
adamdavi3s
Master
Master

I think we need to know a bit more about what you're trying to do here.

Hash128 is usually used to create a composite key of a number of known fields because it is smaller and faster than a concatenate of the fields

swuehl
MVP
MVP

You can use system functions to query the name and number of fields in a table.

Iterate over the field names and create variable with a concatenated string of your field names, then expand the variable in your hash128() function as argument.

System functions (from the help).

NoOfFields([ 'TableName ' ])

Returns the number of fields in a previously loaded table.

Examples:

LET a = NoOfFields('tab1');

Load *, NoOfFields( ) from abc.csv;

FieldName(nr ,'TableName')

Returns the name of the field with the specified number within a previously loaded table.

If the function is used within a load statement, it must not reference the table currently being loaded.

Examples:

LET a = FieldName(4,'tab1');

T1:
Load a, b, c, d from abc.csv
T2:
Load FieldName (2, 'T1') Autogenerate 1;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Example using QVD file here: Re: How to apply a hash function to all fields

That's almost a circular reference in discussions