Calculate Stock

Hello AppSheet Community

I’ve been trying for two whole days to calculate inventory stock. I’m frustrated because I didn’t think it would be so complicated, especially since there’s no programming involved.

I have a product table, a parent table (movi_inv), and a child table (movi_detalle).

To calculate stock, I have a “Cantidad” column in the movi_detalle table. This column stores positive values ​​for incoming transactions and negative values ​​for outgoing transactions. This means I only need to sum this column and filter by the date.

I want to create a filtered PDF using the list from the product table. So, I created an rptInventario table with the only filter being fecha_cierre (closing date). The idea is that to calculate stock, I should simply sum the transactions in the “Cantidad” column where [movi_detalle].[fecha]<=[_THISROW].[fecha_cierre.].

This is just one of many errors.

Error 1 : Task ‘Paso 1’ Body template. Expression ‘SUM(SELECT(movi_detalle[Cantidad],[ID_producto]=[Lista_productos].[ID_producto]))’ is invalid due to: Error in expression ‘[Lista_productos].[ID_producto]’ : Unable to find column ‘ID_producto’, did you mean ‘Lista_productos’?

Links

Tables

Template

I don’t know what I’m doing wrong.

Hi @koviac

try changing Lista_productos with _thisrow

SUM(SELECT(movi_detalle[Cantidad],[ID_producto]=[_thisrow].[ID_producto]))