Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
andrew001
Contributor III
Contributor III

Join 1:n

hi

I've two table that I joined with left join (1.N)

I'd like to use the Result_table in a pivot table: if I SUM with the MOV column is OK, but I don't know how I have to do with SALDO column, because I need the only  first value by CONTO_KEY

Thank you

TAB_SALDI

CONTO_KEY    OWNER SALDO

10001EUR         XYZ       10000

TAB_MOV

CONTO_KEY    OWNER  MOV

10001EUR         XYZ       200

10001EUR         XYZ       300

10001EUR         XYZ       500

RESULT_TABLE

CONTO_KEY    OWNER SALDO   MOV

10001EUR         XYZ       10000     200

10001EUR         XYZ       10000     300

10001EUR         XYZ       10000      500

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Then check with it

TAB_SALDI:

Load *,CONTO_KEY&'1' AS Key Inline

[

CONTO_KEY,OWNER,SALDO

10001EUR,XYZ,10000

10002EUR,XYZ,20000

];

join

LOAD *,if(Previous(CONTO_KEY)<>Previous(CONTO_KEY),CONTO_KEY&'1',CONTO_KEY&ID) AS Key;

Load * Inline

[

CONTO_KEY,ID,OWNER,MOV

10001EUR,1,XYZ,200

10001EUR,2,XYZ,300

10001EUR,3,XYZ,500

10002EUR,1,XYZ,200

10002EUR,2,XYZ,300

10002EUR,3,XYZ,500

];

Note: conto_key field must be in a order

View solution in original post

10 Replies
MayilVahanan

HI

Use Join:

TAB_SALDI:

Load * Inline

[

CONTO_KEY,OWNER,SALDO

10001EUR,XYZ,10000

];

join

TAB_MOV:

Load * Inline

[

CONTO_KEY,OWNER,MOV

10001EUR,XYZ,200

10001EUR,XYZ,300

10001EUR,XYZ,500

];

regards,

R.MayilVahanan


Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
andrew001
Contributor III
Contributor III
Author

thanks

but I've difficult then in the aggragation in the pivot table, because I can use SUM with MOV column, but with SALDO how do I have to do ?

thanks

MayilVahanan

HI

Please,Can you say your requirement in detail? Sum(SALDO) is enough know for calculating the saldo value?

or if you like to calculate one time means, please use sum(distinct saldo)


Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
andrew001
Contributor III
Contributor III
Author

I'd want to SUM (MOV) but I'd want to consider the only first SALDO by CONTO_KEY

And I'd like to aggregate by CONTO_KEY or CONTO_KEY+OWNER (by pivot)

thanks

TAB_SALDI:

Load * Inline

[

CONTO_KEY,OWNER,SALDO

10001EUR,XYZ,10000

10002EUR,XYZ,20000

];

join

TAB_MOV:

Load * Inline

[

CONTO_KEY,ID,OWNER,MOV

10001EUR,1,XYZ,200

10001EUR,2,XYZ,300

10001EUR,3,XYZ,500

10002EUR,1,XYZ,200

10002EUR,2,XYZ,300

10002EUR,3,XYZ,500

];

MayilVahanan

HI

Please check the attached file.. is ur requirement?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
andrew001
Contributor III
Contributor III
Author

I'd  like to obtain this result, in the pivot table (or by script)

from this

CONTO_KEYOWNERIDsum(MOV)SALDO
10001EURXYZ120010000
10001EURXYZ230010000
10001EURXYZ350010000
10002EURXYZ120020000
10002EURXYZ230020000
10002EURXYZ350020000

to this:

CONTO_KEYOWNERIDsum(MOV)SALDO
10001EURXYZ120010000
10001EURXYZ23000
10001EURXYZ35000
10002EURXYZ120020000
10002EURXYZ23000
10002EURXYZ35000
MayilVahanan

Hi

Check the attached file..

Regards,

R.MayilVahanan

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion

Mayil used If conditions in his expression

instead of If expression you can go with set analysis which is faster

Sum({<ID={1}>} SALDO)

Or can be done within script as

TAB_SALDI:

Load *,CONTO_KEY&'1' AS Key Inline

[

CONTO_KEY,OWNER,SALDO

10001EUR,XYZ,10000

10002EUR,XYZ,20000

];

join

TAB_MOV:

Load *,CONTO_KEY&ID AS Key Inline

[

CONTO_KEY,ID,OWNER,MOV

10001EUR,1,XYZ,200

10001EUR,2,XYZ,300

10001EUR,3,XYZ,500

10002EUR,1,XYZ,200

10002EUR,2,XYZ,300

10002EUR,3,XYZ,500

];

then simply use as Sum(SALDO) as expression.

andrew001
Contributor III
Contributor III
Author

Thank you

a last issue: if the KEY '1' doesn't exists, the first ID is 2, , is there another solution ?

thank you in advance