0

Given:

 A | B | ______|____| key1 | 3 | ______|____| key2 | 5 | ______|____| key3 | 7 | ______|____| key2 | 9 | ______|____| 

Get the output:

 D | E | ______|____| key1 | 3 | ______|____| key2 | 14 | ______|____| key3 | 7 | ______|____| 

I'm trying to use a combination of unique and filter but to no avail.

1 Answer 1

0

Using Query

The QUERY function is better suited to SUM the values in Column B grouped by the values in Column A.

Syntax:   QUERY(data, query, [headers])

=QUERY(A1:B5, "select A, SUM(B) group by A") 

Below are some variations on the formula above.

 Exclude Blanks +----------------------------------------+ | =QUERY(A:B, "select A, SUM(B) | | where A <> '' group by A") | +----------------------------------------+ Custom Headings +----------------------------------------+ | =QUERY(A:B, "select A, SUM(B) | | where A <> '' group by A | | Label A 'Key', SUM(B) 'Total'") | +----------------------------------------+ No Headings +----------------------------------------+ | =QUERY(A:B, "select A, SUM(B) | | where A <> '' group by A | | Label A '', SUM(B) ''") | +----------------------------------------+ 

 

UNIQUE , SUMIF, ARRAYFORMULA

An alternative approach/formula uses the UNIQUE and SUMIF functions. Those functions are then wrapped in an ARRAYFORMULA so that one formula will populate all the necessary rows.

={ UNIQUE(A1:A4), ARRAYFORMULA(SUMIF(A:A, UNIQUE(A1:A4), B:B)) } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.