Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
shamitshah
Partner - Creator
Partner - Creator

Create a key

Hi,

I have the following in the script and need to create a key

fldPeronID & PayrollCode  as key1

in TABLEA

TABLEA:

LOAD

fldPersonID,

TravelTime,

Service

From

[lib://QVD/Time.qvd]

(qvd)

LEFT JOIN

fldPersonID,

PayrollCode

From

[lib://QVD/Payroll.qvd]

(qvd);

Any ideas on how/where I can create the key in TABLEA?

Thanks

1 Solution

Accepted Solutions
kenphamvn
Creator III
Creator III

Hi

you can using Autonumber function to create a number Key, or concatenate two column fldPeronID & PayrollCode  as key after load TABLEA with Join


TABLEA_WITH_NEW_KEY:

Load

Autonumber (fldPeronID & PayrollCode ) as Key,  // or fldPeronID & PayrollCode  as key

*

resident TABLEA ;


Drop table TABLEA ;

Regards

View solution in original post

4 Replies
kenphamvn
Creator III
Creator III

Hi

you can using Autonumber function to create a number Key, or concatenate two column fldPeronID & PayrollCode  as key after load TABLEA with Join


TABLEA_WITH_NEW_KEY:

Load

Autonumber (fldPeronID & PayrollCode ) as Key,  // or fldPeronID & PayrollCode  as key

*

resident TABLEA ;


Drop table TABLEA ;

Regards

luismadriz
Specialist
Specialist

Hi, I think you need to create a new table and drop TABLEA

NewTableA:

NoConcatenate

Load *,

     fldPeronID & PayrollCode as key1

Resident TABLEA;

Drop Table TABLEA;

OmarBenSalem

I'd suggest :

NewTableA:

NoConcatenate

Load *,

    autonumber( fldPeronID & '|' & PayrollCode )as key1

Resident TABLEA;

Drop Table TABLEA;

the reason to seperate between the 2 fields by a | for example; is to make sur the key is unique.

example to illustrate my point :

fldPeronID=100

PayrollCode =10

fldPeronID & PayrollCode =10010

but

fldPeronID=10

PayrollCode =010

fldPeronID & PayrollCode =10010

with that, we create the same for 2 differents set of values !

but if we seperate them by sthing '|', we make sure to have a unique key for each combination.

then we surround the new key by autonumber to make it as a num

shamitshah
Partner - Creator
Partner - Creator
Author

Thanks!