Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

fgiorgio
Contributor

Adding QTY's from 2 tables

Hello good Qlik Community people...

I have 2 warehouses with product QTY's, I need to add the two QTY's into a master table.

What's the simplest way I can achieve this?

Here's a simplified representation of what I'm trying to achieve:

WH Tables.JPG

Thanks in advance!!

Cheers...

Fab

1 Solution

Accepted Solutions

Re: Adding QTY's from 2 tables

You need another table or final table please elaborate

Table1:

LOAD * Inline

[

Product,WH,QTY

A,X,10

B,X,20

C,X,15

];

NoConcatenate

Table2:

LOAD * Inline

[

Product,WH,QTY

A,y,20

B,y,40

C,y,30

];

ResultTab:

LOAD

Product as Prod,

Sum(QTY) as TotalQTY

Resident Table1

Group By Product;

Concatenate(ResultTab)

LOAD

Product as Prod,

Sum(QTY) as TotalQTY

Resident Table2

Group By Product;

NoConcatenate

FinalResult:

LOAD Prod,Sum(TotalQTY) as TotalQTY Resident ResultTab Group By Prod;

DROP Table ResultTab;

OutPut:-

OP4.PNG

7 Replies

Re: Adding QTY's from 2 tables

You dont' need anything here.. Consider as expression like below

Dimension is Product

Sum(QTY)

Or

Sum({<WH = {"x","y"}>} QTY)

prma7799
Honored Contributor III

Re: Adding QTY's from 2 tables

Concatenate two tables...

prma7799
Honored Contributor III

Re: Adding QTY's from 2 tables

Like this you want

Re: Adding QTY's from 2 tables

You need another table or final table please elaborate

Table1:

LOAD * Inline

[

Product,WH,QTY

A,X,10

B,X,20

C,X,15

];

NoConcatenate

Table2:

LOAD * Inline

[

Product,WH,QTY

A,y,20

B,y,40

C,y,30

];

ResultTab:

LOAD

Product as Prod,

Sum(QTY) as TotalQTY

Resident Table1

Group By Product;

Concatenate(ResultTab)

LOAD

Product as Prod,

Sum(QTY) as TotalQTY

Resident Table2

Group By Product;

NoConcatenate

FinalResult:

LOAD Prod,Sum(TotalQTY) as TotalQTY Resident ResultTab Group By Prod;

DROP Table ResultTab;

OutPut:-

OP4.PNG

fgiorgio
Contributor

Re: Adding QTY's from 2 tables

Thanks everyone for your suggestions...

I will see how I can use these concepts on my tables and mark as helpful / correct as applicable...

the example is a bit over-simplified, but the principle is the same...

I have never used concatenate before so it would be good to learn this function...

Thanks again and you will hear from me soon!!

Re: Adding QTY's from 2 tables

Find the attached if tables Table1 and Table2 not required then you can use to drop them by


Drop tables Table1,Table2;

imrasyed
Contributor

Re: Adding QTY's from 2 tables

Hi,

I am a new to Qlik but tried the above requirement.Please let me know if this is what you are looking for.

TABLE1:

LOAD * INLINE [

    Product, WH, QTY

    A, X, 10

    B, X, 20

    C, X, 15

];

TABLE2:

LOAD * INLINE [

    Product, WH, QTY

    A, y, 10

    B, y, 20

    C, y, 15

];

Result:

Load Product,sum(QTY)

Resident  TABLE1

group by Product;

Community Browser