Counting values in 1 column based on a category in another

AnotherExcelGuy

New Member
Joined
Jul 8, 2019
Messages
13
Hello,

I need a formula to count values from one column(Vendor) by the category of another. From there need to sum the value if the count is greater/equal to 2.

EG.)

Category......... Vendor......... Count(formula)........ Value.......... Sum(formula)
Blue ................. ABC................. 2.............................$2............... $7
Blue.................. ABC................. -............................. $5................ -
Blue.................. DEF................ 1.............................. $2................ -
Red................... HJK................ 1............................. $1................. -
Red.................. LMN................ 1.............................. $2................ -
Green............... DEF................ 3............................ $1 ............... $8
Green............... DEF................. -............................. $3................. -
Green............... DEF................. -............................ $4.................. -
Green............... HJK ................ 1 ........................... $2.................. -

In the example above, ABC shows up 2 times in the Blue category, so I want to sum it's Value.
DEF appears 3 times in the Green category, so I want to sum it's value. All other vendors only appear once per category, so I don't need to sum their values.

Hope this makes sense.

Thanks.
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
If I understood correctly, you need something like this:

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:71.29px;" /><col style="width:71.29px;" /><col style="width:71.29px;" /><col style="width:71.29px;" /><col style="width:71.29px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Category</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Vendor</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Count</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Value</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Sum</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td >Blue</td><td >ABC</td><td style="text-align:right; ">2</td><td style="text-align:right; ">$2</td><td style="text-align:right; ">7</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >Blue</td><td >ABC</td><td style="text-align:right; ">0</td><td style="text-align:right; ">$5</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td >Blue</td><td >DEF</td><td style="text-align:right; ">1</td><td style="text-align:right; ">$2</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td >Red</td><td >HJK</td><td style="text-align:right; ">1</td><td style="text-align:right; ">$1</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td >Red</td><td >LMN</td><td style="text-align:right; ">1</td><td style="text-align:right; ">$2</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td >Green</td><td >DEF</td><td style="text-align:right; ">3</td><td style="text-align:right; ">$1</td><td style="text-align:right; ">8</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td >Green</td><td >DEF</td><td style="text-align:right; ">0</td><td style="text-align:right; ">$3</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td >Green</td><td >DEF</td><td style="text-align:right; ">0</td><td style="text-align:right; ">$4</td><td style="text-align:right; ">0</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td >Green</td><td >HJK</td><td style="text-align:right; ">1</td><td style="text-align:right; ">$2</td><td style="text-align:right; ">0</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >C2</td><td >=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,COUNTIFS(A2:$A$10,A2,B2:$B$10,B2),0)</td></tr><tr><td >E2</td><td >=IF(C2>1,SUMIFS($D$2:$D$10,$A$2:$A$10,A2,$B$2:$B$10,B2),0)</td></tr></table></td></tr></table>
 
Upvote 0
Let's say your example is in A1:F10.

Formula to put in C2:
Code:
=IF((A1&B1)<>(A2&B2),COUNTIFS($A$2:$A$10,$A2,$B$2:$B$10,$B2),"")
and copy down

Formula to put in E2:
Code:
=IF(C2>1,SUMIFS($D$2:$D$10,$A$2:$A$10,$A2,$B$2:$B$10,$B2),"")
amd copy down
 
Upvote 0
You are welcome. Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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