Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Merge/combine two tables

Hello everyone,

I have two tables (Care and Model) as I want to combine into a table

Table 1 (Car)

CarID     Car

1             Volvo

2             Ford

Table 2 (Model)

CarID     Model

1             V70

1             S40

1             XC60

2             C-max

2             Focus

The combined table should be so:

CarID       Car       Model

1              Volvo     V70, S40, XC60

2              Ford      C-max, Focus

How should I write the script for this?

Thanks in advance.

1 Solution

Accepted Solutions
pradeepreddy
Not applicable

Re: Merge/combine two tables

At scipt Level....

Cars:

Load * inline

[

CarID,Car

1,Volvo

2,Ford

];

Left Join(Cars)

Model:

Load * inline

[

CarID,Model

1,V70

1,S40

1,XC60

2,C-max

2,Focus

];

NoConcatenate

New_Table:

Load

     CarID,

     Car,

     Concat(Model,',') as Model

Resident Cars

group by CarID,Car;

Drop table  Cars;

Regards,

Pradeep

5 Replies
pradeepreddy
Not applicable

Re: Merge/combine two tables

Instead of script, we can achieve this at Chart level also....

create a straight table and enable the 'NoTotal' option in expression tab

Dimensions: CarID, Car

Expression : =Concat(Model,',')

Regards

Pradeep

Not applicable

Re: Merge/combine two tables

Many thanks Pradeep, I would like to fix it in the script to use "Model" in a straight table-object (not raktabell through chart-objects).

Best regards

Stravan

pradeepreddy
Not applicable

Re: Merge/combine two tables

At scipt Level....

Cars:

Load * inline

[

CarID,Car

1,Volvo

2,Ford

];

Left Join(Cars)

Model:

Load * inline

[

CarID,Model

1,V70

1,S40

1,XC60

2,C-max

2,Focus

];

NoConcatenate

New_Table:

Load

     CarID,

     Car,

     Concat(Model,',') as Model

Resident Cars

group by CarID,Car;

Drop table  Cars;

Regards,

Pradeep

maxgro
Not applicable

Re: Merge/combine two tables

this is the script

but I would keep the 2 tables and, when you need it, concat in chart

Table1:

load * inline [

CarID    , Car

1        ,     Volvo

2        ,     Ford

];

Left join (Table1)

load CarID, concat(Model, ', ') as Model group by CarID;

load * inline [

CarID ,    Model

1     ,        V70

1     ,        S40

1     ,        XC60

2     ,        C-max

2     ,        Focus

];

Not applicable

Re: Merge/combine two tables

It was good, thank you very much.

Best regard

Stravan