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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
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
shiveshsingh
Master
Master

Try this

=SUM({<ProductId = {$(=InventID)}>}StockQty)

prma7799
Master III
Master III

Please share some sample data.

irmantas
Contributor III
Contributor III
Author

Not working, sums all StockQTY of all InventId

irmantas
Contributor III
Contributor III
Author

See up I was shared.

shiveshsingh
Master
Master

Let me check, i thought you are having only one inventID

tamilarasu
Champion
Champion

Could you draw expected output format for below example?

PrashantSangle

Hi,

try with aggr() and distinct

like aggr(Distinct sum(if(InventId=ProductId,(StockQTY))),dimesionfield)

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
irmantas
Contributor III
Contributor III
Author

What does it mean "dimesionfield"?

prma7799
Master III
Master III

dimesionfield (simply your Dimension ) 

Check this

aggr(Distinct sum(if(InventId=ProductId,(StockQTY))),ProductId)