Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kkorynta
Contributor III
Contributor III

Concat in load statement

Hi all,

I'm using this as a reference: http://community.qlik.com/forums/p/32145/124107.aspx#124107

I'm trying to do something similar, where have have ID1 and ID2, where by themselves are not unique, but together it creates a unique ID. I'd like to concatenate the two fields together to create a unique ID in the load statement. Here's the code I have so far

LOAD @1 as [Customer Entity],
@2 as [Staff Entity],
@3 as [Revision No],
@4 as [Last Name],
@5 as [First Name],
@6 as [Entity Qualifier],
@7 as Registered,
@8 as [Provider Type],
text(trim(@9)) as [Code Key],
concat(total @1 &@2, ';') as [Special ID]
FROM [C:\

While this loads, the results is "(internal error)"

Can someone point out my error?

1 Solution

Accepted Solutions
Not applicable

Hi there, notice the concat function will only work in the context of the GUI. If you are working in the script you can concatenate the values as follows:

Load *,

@1 & '-' & @2 as KeyField

from table;

However, I would suggest to use some of the autonumber flavors in order to have the ID's represented as integers instead of linking through text values.

Load *,

autonumber(@1 & '-' & @2) as KeyField

from table;

You can also use:

Load *,

autonumberhash256(@1 , @2) as KeyField

from table;

Regards

View solution in original post

3 Replies
Not applicable

Hi there, notice the concat function will only work in the context of the GUI. If you are working in the script you can concatenate the values as follows:

Load *,

@1 & '-' & @2 as KeyField

from table;

However, I would suggest to use some of the autonumber flavors in order to have the ID's represented as integers instead of linking through text values.

Load *,

autonumber(@1 & '-' & @2) as KeyField

from table;

You can also use:

Load *,

autonumberhash256(@1 , @2) as KeyField

from table;

Regards

kkorynta
Contributor III
Contributor III
Author

Awesome. Thanks.

What kind of concatenation is that article referring to?

Not applicable

The concat function will retrieve and string with the resulting concatenation of the values within a field. For example:

Let's say you have a field named Field1 with values 1,2,3,4.

If you use the function as follows:

concat(Field1,'?')

It will retrieve the following string:

"1?2?3?4"

Regards