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?

19 Replies
effinty2112
Master
Master

Hi Siva,

It would be quite a piece of work to produce a key for every possible combination from 15

No of fields chosen No of ways to combine

1 15

2 105

3 455

4 1365

5 3003

6 5005

7 6435

8 6435

9 5005

10 3003

11 1365

12 455

13 105

14 15

15 1

32767

Good luck!

Andrew

PS I should clarify. We're not talking about 32767 values for a key. We're talking 32767 different keys.

sunny_talwar

Fixed some errors and added the 4th field

Table:

LOAD *,

RowNo() as UK;

LOAD * Inline [

ABC, DEF, GHI, KLM

1, 2, 3, 4

92, 32, 54, 23

3, 4, 2, 2

];

FieldNames:

LOAD * Inline [

FieldName

ABC

DEF

GHI

KLM

];

FinalTable:

LOAD UK

Resident Table;

FOR i = 1 to FieldValueCount('FieldName')

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

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

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

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

TRACE $(vField1);

TRACE $(vField2);

TRACE $(vField3);

TRACE $(vField4);

Left Join (FinalTable)

LOAD UK,

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

Resident Table;

NEXT i

Anonymous
Not applicable
Author

Thanks Sunny, But I have FieldName with 15 properties. I don't know where to use my properties and fieldname in your code. Could you please guide me?

sunny_talwar

Share few rows of raw data

Anonymous
Not applicable
Author

Here is the sample data.

sunny_talwar

Which 15 fields are to be autonumbered here?

Anonymous
Not applicable
Author

Except the Field Name column, all the other columns.

sunny_talwar

See if this helps

sunny_talwar

I guess these are only 15 keys and you might be looking for 225 keys.... not sure if I know of a better way to do this...

Anonymous
Not applicable
Author

Thank you so much Sunny. I'll check it.