Available stock formula: PLEASE help!


I had figured this formula out before, but for some reason I lost it and I just can’t figure it out again. Could someone please take a look at it and help me?!

I want the sum to be the initial stock + purchases - sales - consumption
for each product considering the barcode.

Initial stock column is in table products.
Sales column in table sales.
Purchases column in table purchases.
Consumption column in table consumption.

([initial stock].[products], [barcode]=[_THISROW].[barcode]) + SUM(purchase [Q], [barcode]=[_THISROW].[barcode]) - (SUM(consumption [Q], [barcode]=[_THISROW].[barcode]) + SUM(sales [Q], [barcode]=[_THISROW].[barcode]))

Please help me