Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Finding match in same table

Hello,

I have a table with following columns:

KEYCODETRANS
1FG10
1CO12
1FI21
2FG23
2FI21
3FG43
3CO2

As you can see the KEY has some duplication values, i need a script to check, if the value of column CODE is FG and with the same KEY if CODE's value is CO then Trans of FG minus Trans of CO. for example when key is 1 then 10-12 or when key is 3 then 43-2 .

1 Solution

Accepted Solutions
maxgro
MVP
MVP

this?

1.png

source:

LOAD KEY,

     CODE,

     TRANS

FROM

[https://community.qlik.com/thread/159441]

(html, codepage is 1252, embedded labels, table is @1);

Left Join (source)

load KEY, CODE as CODE2, TRANS as TRANS2 Resident source Where CODE = 'CO';

final:

NoConcatenate load

  KEY, CODE, if(CODE='FG'and CODE2='CO', TRANS - TRANS2, TRANS) as TRANS

Resident source;

DROP Table source;

View solution in original post

2 Replies
maxgro
MVP
MVP

this?

1.png

source:

LOAD KEY,

     CODE,

     TRANS

FROM

[https://community.qlik.com/thread/159441]

(html, codepage is 1252, embedded labels, table is @1);

Left Join (source)

load KEY, CODE as CODE2, TRANS as TRANS2 Resident source Where CODE = 'CO';

final:

NoConcatenate load

  KEY, CODE, if(CODE='FG'and CODE2='CO', TRANS - TRANS2, TRANS) as TRANS

Resident source;

DROP Table source;

Anonymous
Not applicable
Author

Thank you massimo, i really appreciate your help and correct answer.