Sum unique values based on multiple criteria

liulilli

New Member
Joined
Jan 16, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Good morning,
I'm trying to figure out how to obtain the sum of a set of records but I've been unable to do so. The solution proposed here worked perfectly but I've encountered an additional problem while trying to apply it to my dataset.
This is an example of the original dataset

Type of productDateCount
a2020115
b2020117
b2020117
c2020116
a2020125
a2020125
b2020129
c2020122
c2020122
a2021014
b2021015

The desired results would be

CONDITION A5 + 5 + 4 = 14
CONDITION B7 + 9 + 5 = 21
CONDITION C6 + 2 = 8

Basically

  1. If the number in column C is repeated but the date in column B is the same it should only sum that number once
  2. If the number in column C is repeated and the date in column B is different from another instance where the number was the same it should be taken into consideration for the sum
I would need to do this possibly without using pivots or using helper columns.
Thank you so much in advance for your help :)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi

Excel Formula:
=SUM(INDEX(UNIQUE(FILTER($B$2:$C$12,$A$2:$A$12="a")),,2))
 
Upvote 0
Solution
Thank you so much for your help, it works perfectly!
I just need to ask you one additional thing: what if I wanted to do the same thing but only considering from for example 202012 onwards? (The original database goes up until 202111).
 
Upvote 0
Try this

Book1
ABC
1Type of productDateCount
2a2020115
3b2020117
4b2020117
5c2020116
6a2020125
7a2020125
8b2020129
9c2020122
10c2020122
11a2021014
12b2021015
13
14CONDITION
15a14
16b21
17c8
Sheet1
Cell Formulas
RangeFormula
B15:B17B15=SUM(IF(($A$2:$A$12=A15)*MATCH($A$2:$A$12&$B$2:$B$12&"|"&$C$2:$C$12,$A$2:$A$12&$B$2:$B$12&"|"&$C$2:$C$12,0)=ROW($A$2:$A$12)-1,$C$2:$C$12))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Try this

Book1
ABC
1Type of productDateCount
2a2020115
3b2020117
4b2020117
5c2020116
6a2020125
7a2020125
8b2020129
9c2020122
10c2020122
11a2021014
12b2021015
13
14CONDITION
15a14
16b21
17c8
Sheet1
Cell Formulas
RangeFormula
B15:B17B15=SUM(IF(($A$2:$A$12=A15)*MATCH($A$2:$A$12&$B$2:$B$12&"|"&$C$2:$C$12,$A$2:$A$12&$B$2:$B$12&"|"&$C$2:$C$12,0)=ROW($A$2:$A$12)-1,$C$2:$C$12))
Press CTRL+SHIFT+ENTER to enter array formulas.
Both formulas work but maybe this works better because in the original database I have columns between date and count that I don't need to take into consideration and I'm afraid that shift-del's formula wouldn't work (even though it works in the sample as I've already said). Thank you so much!
 
Upvote 0
I just need to ask you one additional thing: what if I wanted to do the same thing but only considering from for example 202012 onwards? (The original database goes up until 202111).

I'm using an Excel table (Tabelle1).

Excel Formula:
=LET(
_t,UNIQUE(Tabelle1),
_type,INDEX(_t,,1),
_date,INDEX(_t,,2),
_count,INDEX(_t,,3),
_filter,FILTER(_count,(_type="a")*(_date>=202012),0),
SUM(_filter))
 
Upvote 0
T
I'm using an Excel table (Tabelle1).

Excel Formula:
=LET(
_t,UNIQUE(Tabelle1),
_type,INDEX(_t,,1),
_date,INDEX(_t,,2),
_count,INDEX(_t,,3),
_filter,FILTER(_count,(_type="a")*(_date>=202012),0),
SUM(_filter))
Thank you! Would it be possible without formatting as a table?
 
Upvote 0
Just replace the table name with the table range.
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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