Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
theviking
New Contributor II

Cartesian product in QV

Hi,

I would like to create the cartesian product by joining two tables. Table1 is read into QV from a database and the other is generated internally within QV. An example of what I would like to do is:

Table1

Field1 Field2 Field3

1 A 22

2 B 71

Table2

Field2

A

B

C

The "join" should result in the following table

Field1 Field2 Field3

1 A 22

1 B -

1 C -

2 A -

2 B 71

2 C -

Any suggestions on how this can be done?

Thanks,

/HJ

1 Solution

Accepted Solutions
Not applicable

AW:Cartesian product in QV

Hi, you can use simple JOINs for it. But i think, this just works for small amount of data. For your example:


LOAD
Field1
FROM
Table1;

OUTER JOIN

LOAD Field1 AS Field2
FROM
Table2;

LEFT JOIN
LOAD
Field1,
Field2,
Field3
FROM
Table1;


Kind regards.

2 Replies
Not applicable

AW:Cartesian product in QV

Hi, you can use simple JOINs for it. But i think, this just works for small amount of data. For your example:


LOAD
Field1
FROM
Table1;

OUTER JOIN

LOAD Field1 AS Field2
FROM
Table2;

LEFT JOIN
LOAD
Field1,
Field2,
Field3
FROM
Table1;


Kind regards.

theviking
New Contributor II

AW:Cartesian product in QV

Thanks!!! Big Smile

It worked like a charm. The only modification I did was to add a distinct option to the first load statement.

LOAD DISTINCT Field1
FROM
Table1;

OUTER JOIN

LOAD Field1 AS Field2
FROM
Table2;

LEFT JOIN

LOAD
Field1,
Field2,
Field3
FROM
Table1;

Many thanks!

/HJ

Community Browser