Sum Unique & Duplicate Rows Only Once

gryce

New Member
Joined
Nov 15, 2017
Messages
7
Hi everyone,

I've got a spreadsheet with thousands of rows of data. We have duplicated some rows of data to make it easier for another group to read through the file. I need to sum up the totals in column B, but I only want to sum unique values and only the first duplicate row from column A.


[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]ColA[/TD]
[TD]ColB[/TD]
[TD]Desired Sum[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BB[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]CC[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]DD[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]DD[/TD]
[TD]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EE[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]17[/TD]
[/TR]
</tbody>[/TABLE]

As you can see, Column A has 3 duplicates, and in my third column I'm showing how I'd like to count them (only the first occurrance; they'll always be the same value in column B).

I need to sum the values of column B, but only when column A is either unique, or the first in a series of duplicates.

Thanks for the attention

Brandon
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
This is an array formula that must be entered with CTRL-SHIFT-ENTER.
Drag formula down as needed.
Excel Workbook
ABC
1ColAColBDesired Sum
2AA22
3AA2
4BB33
5CC22
6DD55
7DD5
8EE11
9FF44
10FF4
1117
Sheet
 
Upvote 0
Barry's formula is much better than mine (I made it way to complicated).
 
Upvote 0
Everyone,

Thanks so much for the responses! This is close, but I believe I've confused matters by adding that virtual column C. In reality there is a distinction and I'll try to illustrate it below. Column C doesn't exist, I'm actually summarizing column B on another worksheet. Additionally in this example I grouped all of my items together for readability, but in fact the duplicates may be mingled throughout the document, and there can be more than one duplication (in some cases 16 duplicates).

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]ColA[/TD]
[TD]ColB[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]CC[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]BB[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]EE[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]BB[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]GG[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]FF[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]JJ[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]II[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Ok, assuming data down to row 100 you can use this formula to get a single total, first row value of each repeated text value

=SUM(IF(A2:A100<>"",IF(MATCH(A2:A100,A2:A100,0)=ROW(A2:A100)-ROW(A2)+1,B2:B100)))

confirm with CTRL+SHIFT+ENTER
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top