Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Join two tables with different structure

Good day!

In my model i try join two tables from excel source:

Source1:

   

IdSum1Sum2
12
13
25
33
46
43
52
63

Source2:

 

IdSum2
165
134
25
334
43
45
56
63

In result i need to get such table:

   

IdSum1Sum2
1265
1334
255
3334
463
435
526
63

3

Model and source file in attachment.

Please, help.

21 Replies
MayilVahanan

Hi,

In that case, you can use Order by Id on both table.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
swuehl
MVP
MVP

Yes, I see:

Source:

load

Autonumber(Recno(),'S1'&Id) as Key,

Id,

Sum1

from [Test (1).xlsx]

(ooxml, embedded labels, table is Source1);

left join(Source)

load

Autonumber(Recno(),'S2'&Id) as Key,

Id,

Sum2

from [Test (1).xlsx]

(ooxml, embedded labels, table is Source2);

Anonymous
Not applicable
Author

Ok. Thanks..

Tell me please, why did you use such values 'S1' 'S2' in Keys?

sorrakis01
Specialist
Specialist

Hi,

Can you upload the original xls?

Thx

swuehl
MVP
MVP

The autonumber() function will use the same counter for an ID within the same QVW, but I want to use a counter per ID occurence per Source table. That's why I added an arbitrary identifiers S1 and S2 to the Autonumber bucket ID for the two source tables.

Anonymous
Not applicable
Author

there're no qvd file in attachment...

Anonymous
Not applicable
Author

Thanks for your help!

But in first table there no field Sum2. In my real model in this field may be some values...

Anonymous
Not applicable
Author

Of course... See attachment

swuehl
MVP
MVP

And how would you like to handle this?

You can rename one of the two Sum2 fields, then join the tables. this should get you all lines, and all Sum2 values.

If you want to add the two Sum2 fields (remember, one has been renamed), you can do this in a subsequent resident load.

Similar if you don't want to add the values, but keep the values from one sheet and drop the other.

sorrakis01
Specialist
Specialist

Hi andrey,

And you can't create a qvd with this structure (Example of Mayil is Good) and after load it with the others qvds?

Regards,