Available Stock considering BarCode Column


I have a Virtual Column called “Available Stock”, with the following formula. The problem is, that it is not considering the bar code of the products and automatically thinks that the Available Stock for all products is the same. How can I add the Bar Code identifier to this formula to differentiate the Available Stock between products?

The BarCode column is in the Products table.

[Initial Stock] + SUM (Purchase [Q]) - (SUM (Consumption[Q]) + SUM (Sales [Q]))

I also tried these but it doesn’t work:

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

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

Thank you