Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Specialist II
Specialist II

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

View solution in original post

5 Replies
PradeepReddy
Specialist II
Specialist II

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
Author

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
Specialist II
Specialist II

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
MVP
MVP

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
Author

It was good, thank you very much.

Best regard

Stravan