sumproduct or countA, but how :)

zyuth

New Member
Joined
Sep 7, 2019
Messages
4
[TABLE="width: 154"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD]Fruits[/TD]
[TD]Years[/TD]
[/TR]
[TR]
[TD]apple[/TD]
[TD="align: right"]2018[/TD]
[/TR]
[TR]
[TD]apple[/TD]
[TD="align: right"]2018[/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD="align: right"]2018[/TD]
[/TR]
[TR]
[TD]banana[/TD]
[TD="align: right"]2018[/TD]
[/TR]
[TR]
[TD]peach[/TD]
[TD="align: right"]2019[/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD="align: right"]2019[/TD]
[/TR]
[TR]
[TD]apple[/TD]
[TD="align: right"]2019[/TD]
[/TR]
[TR]
[TD]melon[/TD]
[TD="align: right"]2019[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]2018[/TD]
[TD="align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]

hi i got this case, can you help me out for the formula? as u can see the answer is 3, but when i change to 2019 the answer is 4. thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
What formula are you using to get this result, and what is the criteria for the calculation


Excel 2013/2016
AB
1FruitsYears
2apple2018
3apple2018
4orange2018
5banana2018
6peach2019
7grape2019
8apple2019
9melon2019
10
1120191
Sheet2
Cell Formulas
RangeFormula
B11=SUMPRODUCT(--(A2:A9="apple"),--(B2:B9=A11))
 
Last edited:
Upvote 0
oh.. you are too specific by putting apple on it. what i want is how much fruit type in 2018 (or base on year that i will put)
 
Upvote 0

Excel 2013/2016
AB
1FruitsYears
2apple2018
3apple2018
4orange2018
5banana2018
6peach2019
7grape2019
8apple2019
9melon2019
10
1120194
Sheet2
Cell Formulas
RangeFormula
B11=COUNTIF(B2:B9,A11)
 
Upvote 0
to be truth i like your first answer, cause right now is only count for year only. beside the answer should be (2018=3) and (2019=4)
 
Upvote 0
beside the answer should be (2018=3) and (2019=4)

Perhaps something like this?

B11 =SUMPRODUCT((B$2:B$9=$A11)/(COUNTIFS(B$2:B$9; B$2:B$9&""; A$2:A$9; A$2:A$9&"")+(B$2:B$9<>$A11)))
B12 =SUMPRODUCT((B$2:B$9=$A12)/(COUNTIFS(B$2:B$9; B$2:B$9&""; A$2:A$9; A$2:A$9&"")+(B$2:B$9<>$A12)))

[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td=bgcolor:#0070C0]
Fruits
[/td][td=bgcolor:#0070C0]
Years
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]
apple​
[/td][td]
2018​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]
apple​
[/td][td]
2018​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]
orange​
[/td][td]
2018​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td]
banana​
[/td][td]
2018​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]
peach​
[/td][td]
2019​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td]
grape​
[/td][td]
2019​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
8
[/td][td]
apple​
[/td][td]
2019​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
9
[/td][td]
melon​
[/td][td]
2019​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
10
[/td][td]
[/td][td]
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
11
[/td][td=bgcolor:#FFFF00]
2018​
[/td][td=bgcolor:#D2ECB6]
3​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
12
[/td][td=bgcolor:#FFFF00]
2019​
[/td][td=bgcolor:#D2ECB6]
4​
[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]
 
Upvote 0
Well, you'd probably get a better answer if you provided more information on what you require....
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
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