Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.

Calculating a price from several items.

Hi all, My first app, 

My tables

1) List of raw materials (Items).

ItemID (this UID)TitlePrice  
IID1Bolt1  
IID2Nut1.20  
IID3Washer.5  
IID4Locking Nut1.50  

2) List of products made from the raw materials (Products).

ProductID (this UID)TitlePrice   
PID1Standard FixingThis is what I want calculated  
PID2Locking FixingThis is what I want calculated  

3) List of raw materials associated with each product. (Product_Items)

ProductItemIDProductID (ref to products table)ItemID (ref to Items Table)Quantity  
PIID1PID1IID11  
PIID2PID1IID21  
PIID3PID1IID32  
PIID4PID2IID11  
PIID5PID2IID32  
PIID6PID2IID41  

I need a virtual column in Products that gives me a total price by returning the Item price (in items)* Quantity of each of the raw materials used (in the product_items table)

All the REFs: are in place, the product_items correctly links the items from Items to Products. I now just need the formula that will change as raw materials cost change.

I have to go, my 2 yr olds waking but I hope it makes sense, I will proof read tomorrow.

Thanks for your help on this.

0 1 80
1 REPLY 1

Hi,

The most explanatory way is to add in Product_Items table some VC (short for virtual column)
[Material_Price] = [ItemID].[Price] DOT BETWEEN ].[
[Item_Price] = [Material_Price]*[Quantity]

Then in Products table VC
[Price] = SUM([Related_Product_Itemss][Item_Price]) NO . BETWEEN ][


VC are to be avoided because they have a great impact over performance but for your first app and "to get there quick", they'll do.

I hope it helps!

Top Labels in this Space