Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jduluc12
Creator
Creator

Pivot table question

Hi,

My data set looks like this:

Main:

ID

cust

Amount


1Cust A20
2Cust B30
3Cust A40
4Cust B

50

Second:

IDTypename
1A
3B
2C

The chart should look like this:

CustAmount 1 Amount 2
Cust A20 + 40
Cust B3050

So Amount 1 is sum of amounts for those IDs which are present in both Main and Second table and

Amount 2 is sum of amounts for those IDs which is present only in Main table.

For Cust A, both IDs 1 and 3 are present in both tables so the Amount 1 column has 20 + 40

For Cust B,  ID# 2 is present in both tables so Amount 1 has 30 and ID# 4 is present only in Main table so Amount 2 column has 50.

Jean

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

Script:

Second:

Mapping LOAD ID, 'Cust '&Typename as cust

FROM [https://community.qlik.com/thread/305069]

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

Main:

LOAD

    if(Applymap('Second',ID,'Null')='Null',1,0) as Flag,

    ID,

    cust,

    Amount

FROM [https://community.qlik.com/thread/305069]

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

Straight/Pivot Table:

Dim = cust

Expression1:

sum({<Flag={0}>}Amount)

Expression2:

sum({<Flag={1}>}Amount)

OUTPUT:

View solution in original post

1 Reply
Frank_Hartmann
Master II
Master II

Script:

Second:

Mapping LOAD ID, 'Cust '&Typename as cust

FROM [https://community.qlik.com/thread/305069]

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

Main:

LOAD

    if(Applymap('Second',ID,'Null')='Null',1,0) as Flag,

    ID,

    cust,

    Amount

FROM [https://community.qlik.com/thread/305069]

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

Straight/Pivot Table:

Dim = cust

Expression1:

sum({<Flag={0}>}Amount)

Expression2:

sum({<Flag={1}>}Amount)

OUTPUT: