Simplicty and flexibility!


Sum of rows in the row


Started by George Washington
Search
You will need to Sign In to be able to add or comment on the forum!

Sum of rows in the row

Hi there,

I have two tables, the head (order_head) and the related rows (order_rows) representing orders from customers and containing also the costs to manufacture the products and manage the order. Much of the costs are directly related to the row itself (e.g the costs of raw materials), but some are defined for the order as a whole and need to be split: for instance, costs related to raw material are in the row, but costs related to some certificates are in the head. To define how much is the profit of an order I need to use the formula: [ (sell price) - (raw material costs) - (cost of the certificates related to the row)]. So, I need to define how much of the total certificates cost is to be assigned to the row. To due that I have to divide the sell price of the item for the total value of the order.

Example:

Order n. 180, composed by three items (A, B, C), has a costs for certificates of 80 euros (this value is in the head table). The items A has a sell price of 200 euros, B 250, C 350. To split the certificate cost I use the formula [ (certifcate cost) / (total value of the order)] -> 80/800. Then I multiply the result for the sell price of each order: the item A has 20 euros for certificate cost, B 25, C, 35. Now I can calculate the profit for each item using the above formula: [ (sell price) - (raw material costs) - (cost of the certificates related to the row)].

In the head of the table there is a virtual field with the total value of the order (derivation: sum of order_row sell_price): the problem is that if I can try to put a virtual field in the row that lookups the total value in the head, Dataease enters in a loop.

Is there a solution?


Written by George Washington 17/01/17 at 08:31:26 Dataease [{8}]FIVE

Re:Sum of rows in the row

I've got myself an answer: I need to create a relationship on order_rows table with itself.


Written by George Washington 17/01/17 at 10:41:22 Dataease [{8}]FIVE
DG3_ForumList