# Finding the right formula in google sheets

I am by far not tech savvy enough to be doing this so I'm asking for help. I've created drop down lists to make my job easier for data entry however they want everything to total up a certain way and I'm not finding a way to do it. I have tried the all the =SUM... but my lists are on multiple sheets, and I need the total to only be a certain product. My function is coming out longer than they will allow so I need help. Without giving away what I'm working on I'll just lay it out and see if y'all can help.

If("product" in Incoming!B2:B,Outgoing!B2-B then Incoming!C2:C-Outgoing!C2-C)

Column B is the product and Column C is the amount of product brought in and sold All this information is going onto a sheet called Inventory.

I have spent countless hours googling, watching YouTube videos, searching through pre-made code and trying anything I can think of to find a solution. Maybe I'm just going crazy and trying to do something I have no clue how to do. Any help would be appreciated.

• Hi and welcome. Without giving away what I'm working on That's a problem because it affects the information you provide us. May I try clarify? Please correct me if I'm wrong. You are tracking product quantities. You have at least two sheets "Income" and "Outgoing". A product on the Incoming sheet might (or not) be on the "Outgoing" Sheet. What you want is, for each product on the Incoming Sheet, you want to calculate the total quantity Incoming less the total quantity (if any) Outgoing. Is that right? Maybe you also want to do this with some date ranges but you haven't mentioned this. Commented Nov 2, 2021 at 8:46

`=query({query(Incoming!A3:C,"select A, Sum(C) where A is not null GROUP BY A label Sum(C) ''",-1),iferror(arrayformula(vlookup(sort(unique(filter(Incoming!A3:A,Incoming!A3:A<>"")),1,1),query(Outgoing!A3:C,"select A, Sum(C) where A is not null GROUP BY A label Sum(C) ''",-1),2,0)),0)},"select Col1, Col2, Col3, Col2-Col3 label Col1 'Product',Col2 'Incoming',Col3 'Outgoing',Col2-Col3 'Net'")`