Reputation: 3031
I need a formula to sum a column of values. But I only want to sum the rows that have an ID that are unique among the entire range. See the example below where I have 6 rows, but there are only 3 unique IDs. My ideal outcome is a sum of 6 by adding one instance of UNIQUEID-00A, UNIQUEID-00B, and UNIQUEID-00C.
Notes:
A2:A
to target the IDs rather than having to specify a specific start and end point like A2:A7
.See the linked Google Sheet below for a copy of this.
ID | Value |
---|---|
UNIQUEID-00A | 1 |
UNIQUEID-00B | 2 |
UNIQUEID-00C | 3 |
UNIQUEID-00A | 1 |
UNIQUEID-00B | 2 |
UNIQUEID-00C | 3 |
https://docs.google.com/spreadsheets/d/1bU4J1RL5S0a_NvFjW_KVpiKi8603Tj9iVPeNzBlw-OA/edit?usp=sharing
Upvotes: 2
Views: 5164
Reputation: 1
use:
=SUM(SORTN(B3:B, 9^9, 2, A3:A, 1))
B
column9^9
2
A
column1
Upvotes: 1
Reputation: 3177
Given the above table in A1:B7:
=sum(index(unique(A2:B7),,2))
UNIQUE returns the distinct rows of the range, INDEX (with column parameter = 2) to return only the value column, then SUM the result.
EDIT Based on the updated requirements, with the IDs in, for example, column A and the values to be summed in column C, use something like:
=sum(index(unique({A2:A,C2:C}),,2))
I'm assuming that there is no data below your input table. The UNIQUE here will return an extra blank row because of the unlimited range, but SUM will disregard it.
Upvotes: 3