Iterative calculation

"Hello community,

I think Appsheet should consider iterative calculation.

To explain what I am suggesting, I must clarify the context. Currently, I have an input table that represents the items I purchase and a production table that indicates the products I make using these inputs. It is important to note that productions can involve both inputs and other productions but not the parent production, resulting in a nested multi-level structure.

For example:

Level 1 production (bread) using inputs (flour and water).
Level 2 production (hot dog) using an input (sausage) and a Level 1 production (bread).
I can have "n" level productions.

I implemented bots that update the tables using a field called [update] and an action that increments this field every time there is a change to the table. So far everything works fine. However, I would like these actions to run indefinitely until all iterations required to recalculate costs are completed. I don't want the action to stop after the first iteration; instead, I want it to apply to all related rows where the mentioned production is located.

I have also tried to create virtual columns for the calculation but it returns an error Ran out of resouces evaluating

I think Appsheet should consider iterative calculation.

Status Open
1 4 112
4 Comments

Hello @Gustavo_Eduardo,

If AppSheet runs into that error it means that your calculation is looping on itself, you could solve this by adding another table that moves the inventory calculation elsewhere, for example:

You could add an "Inventory" table, so that once an item is added to the "input" table it will be added to the "Inventory" as well, and the available amount of the new item depends on how much of it arrives on the "input" table and how much of it is spend on the "production" table.

And the same thing would happen in the production table, once a new product is created there it should be populated in the inventory as well, and if it is used in the creation of any other production items it's available amount should go down.

That way you will only ever "pull" your input or production items from one table, which will make everything a lot easier, and you'll be able to calculate the available amounts using a simple expression on a virtual column.

Gustavo_Eduardo
Silver 5
Silver 5

Me gusta tu forma de pensar. He ideado algo así. He creado una tabla de soporte, podría decirse que es una tabla espejo llamada Producciones_Support. 

Digamos que de la tabla de producciónes he clonado dos columnas y he creado una acción que añade filas a otra tabla, concretamente de la tabla producciones a la tabla producciones_support. Las filas que necesito son (Row Id que se almacena en producciones_support como [Producciones Row ID]) y el label de la tabla producciones que se almacena como label en producciones_support. Cada vez que se agrega un registro en la tabla de producciones, se agrega en la tabla producciones support, con un nuevo id. Sin embargo, los Row ID de la tabla producciones que existen en la columna producciones ID de la tabla producciones support no desencadenan la acción de copiar una nueva fila.

Finalmente, en la tabla producciones_support he creado una columna virtual llamada [costo_unitario] que toma el valor de la columna real [costo_unitario] de la tabla producciones. Así, cuando hago el cálculo, no refiero sobre la tabla padre sino sobre la tabla clon. 

Ahora estoy por aplicar esta idea, dime si es similar a lo que me dices? Te agradezco mucho Rafael, tu aporte.  

Creo que es algo similar, ahí estarías creando una tabla de soporte exclusiva para almacenar los productos únicos de las producciones, que sería básicamente la tabla "Inventario" que te mencione pero solo para producción.

Creo que debería funcionar, aunque no sé como manejarías los productos de la tabla "input" de esta manera.

Gustavo_Eduardo
Silver 5
Silver 5

Ok. Rafael, mil gracias. Yo voy a intentarlo y luego publicaré la solución en caso que lo consiga. Te agradezco nuevamente y, te estaré etiquetando amigo.