Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

shamitshah
Contributor

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
Contributor III

Re: Create a key

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

4 Replies
kenphamvn
Contributor III

Re: Create a key

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
Valued Contributor

Re: Create a key

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
Esteemed Contributor

Re: Create a key

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
Contributor

Re: Create a key

Thanks!

Community Browser