Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
EAK
Contributor
Contributor

sum from seperate columns

Hi everyone,

ı need urgent solutions for my below concern

I have 2 table as stated below. I need 3rd coloumn stated as expected result which sum of Codes from table1

I added result in italic. But some  of them sum of DK3 from Table 1 , some of them from Dk4.

is it possible to write  a expression for cover all fields? ( sum from seperate columns)

The issue is a bit urgent

Thanks

@sunny_talwar

Table1:

DK3        DK4        Total

100         1001        500

101         1010        200

102         1021        300

102        1023        400

Table2:

PL                     References_Code              Expected Result 

Income                 100;101                                                    700

Expense              1021                                                           300

Provision            1023                                                             400

 

1 Solution

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

Script

LOAD *,
IF(DK3='100' or DK3='101',Total,
IF(DK4='1021',Total,
IF(DK4='1023',Total))) AS tempTotal,

IF(DK3='100' or DK3='101','Income',
IF(DK4='1021','Expense',
IF(DK4='1023','Provision'))) AS PL;


Table1:
LOAD * Inline[

DK3,DK4,Total

100,1001,500

101,1010,200

102,1021,300

102,1023,400];

DROP Field Total;
RENAME Field tempTotal TO Total;

EXIT SCRIPT;

Output

peter_brown_0-1661984294177.png

 

 

 

View solution in original post

2 Replies
BrunPierre
Partner - Master
Partner - Master

Script

LOAD *,
IF(DK3='100' or DK3='101',Total,
IF(DK4='1021',Total,
IF(DK4='1023',Total))) AS tempTotal,

IF(DK3='100' or DK3='101','Income',
IF(DK4='1021','Expense',
IF(DK4='1023','Provision'))) AS PL;


Table1:
LOAD * Inline[

DK3,DK4,Total

100,1001,500

101,1010,200

102,1021,300

102,1023,400];

DROP Field Total;
RENAME Field tempTotal TO Total;

EXIT SCRIPT;

Output

peter_brown_0-1661984294177.png

 

 

 

EAK
Contributor
Contributor
Author

Thanks a lot Peter👍