4 Replies Latest reply: Apr 26, 2012 10:04 AM by Martijn ter Schegget

# Just for QVW experts.Combinatorial analysis

Hello everyone,

I´ve this simple table:

ITEM

A

B

C

D

Then i need to make this...

ITEM_X

A

AB

AC

ABC

ABD

ACD

ABCD

B

BA

BC

BD

BAC

BACD

And so on..

Tks

• ###### Re: Just for QVW experts.Combinatorial analysis

Hi

How's this? Please look at the attachment.

Regards

Jonathan

• ###### Re: Just for QVW experts.Combinatorial analysis

Ok.. so nice...

But features like 'AA' or 'AAA' or 'BB' is not valid...

• ###### Just for QVW experts.Combinatorial analysis

Jonathan....

Another problem.

The table ITEM can be A,B,C,D... OR   A,B,C,D,E,G.... OR A,B...

This table can have a lot of records...

• ###### Re: Just for QVW experts.Combinatorial analysis

Hi Joao,

Built a QVW to generate this; see the attachment. Not really optimized though...

One other word of warning: the number of combinations grows very fast once you have a larger number of items in your original list (a bit over 100.000 for 8 items, nearly 1 million for 9 items, nearly 8,5 million for 10 items)!

Regards,

Martijn ter Schegget

The Implementation Group

PS: The script (in case something messes up the attachment):

```values:
value
A
B
C
D
E
F
G
H
];

tmp_nrofvalues:
count(value) as nrofvalues
RESIDENT values;

LET vNrOfValues = peek('nrofvalues');

DROP TABLE tmp_nrofvalues;

combinations:
null() as combination
AUTOGENERATE (0);

FOR vOuterLoop = 1 to \$(vNrOfValues)

fixed_length_combinations:
'' as fixed_length_combi
AUTOGENERATE (1);

FOR vInnerLoop = 1 to \$(vOuterLoop)
value
RESIDENT values;

fixed_length_combi,
value,
fixed_length_combi & value as fixed_length_combi_new
RESIDENT fixed_length_combinations
WHERE index(fixed_length_combi, value) = 0;

fixed_length_combi_new
RESIDENT fixed_length_combinations;

DROP FIELDS fixed_length_combi, value FROM fixed_length_combinations;
RENAME FIELD fixed_length_combi_new TO fixed_length_combi;
NEXT vInnerLoop