# How do I get the sum of the results from a calculation for each row?

I have the following `table1` with multiple rows:

``````+---------+-------+--------+
| Element | Price | Output |
+---------+-------+--------+
``````

Then I have another `table2`:

``````+----------+------+
| Quantity | Cost |
+----------+------+
``````

What I want for the `Cost` column is to get `ROUNDUP(table2.Quantity/table1.Output)*table1.Price` of each row of `table1` and then get the `SUM` of each of the results. In other words:

``````ROUNDUP(table2.Quantity1/table1.Output1)*table1.Price1 +
ROUNDUP(table2.Quantity1/table1.Output2)*table1.Price2 +
ROUNDUP(table2.Quantity1/table1.Output3)*table1.Price3 + ...
``````

## 1 Answer

This answer assumes that table2 has the same elements as table 1 and in the same order. It does not use Excel tables but ordinary ranges. It uses an array formula which is created with Ctrl-Shift-Enter. Consider the two ranges below:

In some cell, e.g., K1, create the formula

``````=ROUNDUP(SUM((F2:F12/C2:C12)*B2:B12),0)
``````

but while in that cell press Ctrl-Shift-Enter.

The formula bar should show:

and cell K1 should show 58.

Using Excel tables, the formula looks like this: