How can I get the sum of rows based on column value before it? [SOLVED]

Let’s say I have two “types” ABC and DEF in column A and I have the cost value of the item in column B.
How can I get the total sum of “ABC” and “DEF” in coumn E?

I have enclosed a sample spreadsheet.

BTW - I cannot “sort” values because of other column values.

Thanks ahead for any suggestions or solutions - and be safe.

Column_Addition.ods

Thank you, this is a good question, this is an example that a good question contains half the answer. You asked “how to sum if…”. The answer is the SUMIF() function. Enter into E2 the formula

=SUMIF($A$2:$A$20;D2;$B$2:$B$20)

with result $302.50

Stretch it down and get in cell E3

=SUMIF($A$2:$A$20;D3;$B$2:$B$20)

with result $344.00

This is usually solved by either of …

  • Conditional sum using SUMIF() or a similar function.

    This is “live” ; automatically updated with each data entry/edit. It may need additional measures to catch user error.
  • A pivot table

    This requires manual update to reflect new/edited data. Data entry error is more likely to be apparent in the result table.

Both approaches are illustrated in the attached file.

Both “keme” and “JohnSUN” provided the same answer and it does provide me with the solutions. Thanks guys.

Then please click the tick-circle at JohnSUN’s answer (he beat me by a couple of minutes, by the looks of it ; didn’t notice that there was another answer until now). Wait for a few seconds and the circle will turn green. That marks the answer as a solution, and your issue is marked as solved and can be closed. It also awards John (and yourself) some karma score.

Next, consider removing your “thank you” posting here and entering it as a comment to your question instead. In its current state it poses as an alternate solution, which it isn’t.

This is a comment to said “answer”. Removing the answer will also remove comments on the answer, which cleans up the entire entry.

Thank you!