Sum last occurrences of unique values in column

natesreich

New Member
Joined
Dec 5, 2020
Messages
1
Hi All -

Thanks for this great community.

I am trying to sum the last occurrences of unique values in a column for "company1".

For example:

Fe3X0Ye[1].png

Expected output: 1+2=3

So, sum if:
- Column A = "company1"
- Is last occurrence of the unique value in column B

I imagine it should be something like:
=SUMIFS(C:C,A:A,"company1",IS_LAST_OCCURRENCE_TRUE_OR_FALSE(B:B))

But, what can I use for IS_LAST_OCCURRENCE_TRUE_OR_FALSE?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Personally, I would use a helper column. It may be possible without if you have the UNIQUE and FILTER functions available. (Please update your account details to show which version of excel you are using by clicking your user name at the top right of this page, then going to 'Account Details', checking the box for your version of excel, then scrolling down and saving changes).

Book1
ABCD
1company1a12
2company1b11
3company2c11
4company1a21
5
63
Sheet1
Cell Formulas
RangeFormula
D1:D4D1=COUNTIFS(A1:A$4,A1,B1:B$4,B1)
D6D6=SUMIFS($C$1:$C$4,$A$1:$A$4,"Company1",$D$1:$D$4,1)


If there is existing data in other columns then there might be something that could be used as an alternative to the helper column.
 
Upvote 0
Hi

I agree with Jason, it makes all the sense to use an auxiliary column, the solution is simple and easy to maintain.

Just for fun this is a solution without the new functions lile unique() or filter().

In H5:

=SUM(IF(IF($C$5:$C$100=G5;COUNTIFS(OFFSET($C$5:$C$100;ROW($C$5:$C$100)-ROW($C$5);;ROWS($C$5:$C$100)-(ROW($C$5:$C$100)-ROW($C$5))+1);$C$5:$C$100;OFFSET($D$5:$D$100;ROW($C$5:$C$100)-ROW($C$5);;ROWS($C$5:$C$100)-(ROW($C$5:$C$100)-ROW($C$5))+1);$D$5:$D$100);0)=1;$E$5:$E$100;0))

This is an array formula, you have to confirm it with CTRL-SHIFT-ENTER.
Copy down.


Book1
ABCDEFGHI
1
2
3
4
5Company Aa1Company A29
6Company Aa2Company B22
7Company Ab3Company C11
8Company Bb4
9Company Ac5
10Company Bc6
11Company Ac7
12Company Ad8
13Company Ae9
14Company Be10
15Company Ce11
16Company Be12
17
18
Sheet4
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,598
Members
449,089
Latest member
Motoracer88

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