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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Autonumber function

Guys,

I have 15 columns in a table, but I want to generate keys using autonumber function for all the combinations of that 15 columns. Is it possible to do by script wise?

1 Solution

Accepted Solutions
sunny_talwar

See if this helps

View solution in original post

19 Replies
sunny_talwar

Should be possible...

AutoNumber(Field1&Field2&Field3&.....&Field15) as Key

Kushal_Chawda

Autonumber (key1&'|'&Key2&'|'&.........)

Anonymous
Not applicable
Author

No, I want all the combinations. I mean

for example, for three columns itself I want these much of combinations,

AutoNumber(Field1&Field2&Field3) as Key

AutoNumber(Field1&Field3&Field2) as Key1

AutoNumber(Field3&Field1&Field2) as Key2

AutoNumber(Field2&Field1&Field3) as Key3

.

.

.

So, it goes on. Likewise, is it possible to generate key for all the combinations of 15 columns.

sunny_talwar

I think so... the only change I would do is this

AutoNumber(Field1&Field2&Field3, 'Key') as Key

AutoNumber(Field1&Field3&Field2, 'Key1') as Key1

AutoNumber(Field3&Field1&Field2, 'Key2') as Key2

AutoNumber(Field2&Field1&Field3, 'Key3') as Key3

.

.

.

Anonymous
Not applicable
Author

Thank you. But do I have to write all the combinations of 15 columns or can I use loop function for that?

Kushal_Chawda

that menas 15 * 15 = 225 combinations?

Anonymous
Not applicable
Author

yes exactly..

sunny_talwar

I guess you might be able to loop... let me see if there is an option

sunny_talwar

This is for 3 fields, but can be expanded to 15 fields

Table:

LOAD *,

RowNo() as UK;

LOAD * Inline [

ABC, DEF, GHI

1, 2, 3

92, 32, 54

3, 4, 2

];

FieldNames:

LOAD * Inline [

FieldName

ABC

DEF

GHI

];

FinalTable:

LOAD UK

Resident Table;

FOR i = 1 to FieldValueCount('FieldName')

LET vField1 = FieldValue('FieldName', $(i));

LET vField2 = FieldValue('FieldName', If($(i)+1 > 3, FieldValueCount('FieldName') - $(i) + 1, $(i)+1));

LET vField3 = FieldValue('FieldName', If($(i)+2 > 3, FieldValueCount('FieldName') - $(i) + 2, $(i)+2));

Left Join (FinalTable)

LOAD UK,

AutoNumber([$(vField1)]&'|'&[$(vField2)]&'|'&[$(vField3)], 'Key'&$(i)) as [Key$(i)]

Resident Table;

NEXT i