Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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.
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
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?
Share few rows of raw data
Here is the sample data.
Which 15 fields are to be autonumbered here?
Except the Field Name column, all the other columns.
See if this helps
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...
Thank you so much Sunny. I'll check it.