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: 
irmantas
Contributor III
Contributor III

SUM with IF

Hi all,

I have two tables without a shared key.

     

ProductIdSalesQty
X5
Y2
Z6

 

InventIdStockQty
X100
Y50

In Pivot I want show sum of SalesQTY and sum of StackQTY. Were ProducId = InventId.

sum({ <ProductId=InventId>} StockQty) is not working.

26 Replies
prma7799
Master III
Master III

Try this

sum({ <ProductId=P(InventId)>} StockQty)

tamilarasu
Champion
Champion

Hi Irmantas,

Try

Sum(IF(ProductId=InventId,StockQty) )

shiveshsingh
Master
Master

Capture.PNGCapture.PNG

please try this way

irmantas
Contributor III
Contributor III
Author

Thank you PM it's works.

What does it mean "P" in P(InventId) ?

irmantas
Contributor III
Contributor III
Author

Problem in duplicating StokQty, when Sales is more then one for the same ProductId.

irmantas
Contributor III
Contributor III
Author

Sorry PM I was made mistake, but it's do not work. With this I get sum of all StockQty. As in Ex. 150

irmantas
Contributor III
Contributor III
Author

Duplicating sum of StockQTY.

In ex: if ProductId "X" have more entries, StockQTY is sum of 100*(num of entries)

shiveshsingh
Master
Master

Can you share sample data which is resulting in duplicacy?

irmantas
Contributor III
Contributor III
Author

My real load data:

In pivot StockQTY expression is sum(if(InventId=ProductId,(StockQTY)))

As we can see SalesQTY have 5 entries. StockQTY 9293,220=1858,644*5

How I can reach this problem?