# Calculating Total Cost from multi-select input

Topic Labels: Base design
Solved
3441 3
cancel
Showing results for
Did you mean:
4 - Data Explorer

Hi,

I am trying to build a formula to properly calculate the cost for an order whose input is a multi-select field of products.

I did my best to follow these recommendations:

The tables are Products, Orders, and Line Items.

The Products Table (includes lookup to the Line Items Table).

The Orders Table (includes lookup to a Companies Table (not pictured))

The Line Items Table (includes lookup to the Products Table)

I don’t know how to create the field for Total Cost in the Line Items Table to be able to calculate total cost dependent upon which products are linked. On the front end a user would select which products they wish to include in their order.

Any pointers or reference to existing community content would be appreciated. Thanks!

1 Solution

Accepted Solutions
18 - Pluto

Welcome to the community, @Godel!

Are you saying that you just want to add up those unit costs to give you a total cost? You would just need to create a rollup field called “Total Cost”, have it point to the Products table (because Products is your linked record field), then choose the Unit Cost field, and then type the formula: `SUM(values)`

That would be the way to do it based on your current setup, although a likely better setup would be to have each record in your line items table include one product instead of multiple products. Then, your rollup field would be back in your orders table.

3 Replies 3
18 - Pluto

Welcome to the community, @Godel!

Are you saying that you just want to add up those unit costs to give you a total cost? You would just need to create a rollup field called “Total Cost”, have it point to the Products table (because Products is your linked record field), then choose the Unit Cost field, and then type the formula: `SUM(values)`

That would be the way to do it based on your current setup, although a likely better setup would be to have each record in your line items table include one product instead of multiple products. Then, your rollup field would be back in your orders table.

4 - Data Explorer

Very cool @ScottWorld

I think I’m in better shape than I was before.

Is this more in line with what you were thinking?

18 - Pluto

Yeah, that looks pretty good!