Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
MVP
MVP

Re: hash128() without knowing the number of fields

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
Master
Master

Re: hash128() without knowing the number of fields

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

Highlighted
MVP
MVP

Re: hash128() without knowing the number of fields

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

Highlighted

Re: hash128() without knowing the number of fields

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

That's almost a circular reference in discussions