Counting data using countif/countifs formula

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all,

i need some excel formula to solve this below problem. with using COUNTIF/COUNTIFS how to counting data with 3 mode ;

namepropertychecking
robertpcyes
monitor
davidkeyboardno
alfienotebook(empty cell/blank cell)
lcd
mouse
zidanroseyes
glass
etc..

<tbody>
</tbody>

i want to count with criteria based on adjacent value "name" column related with "checking" column
1) counting data "name" with "yes" criteria?
2) counting data "name" with "yes" & "no" criteria?
3) counting data "name" with blank "" criteria?
4) counting data "property" with criteria contains "name" and "yes" criteria

any assistance would be greatly appreciated..

regards

m.susanto
 
I suggest you use a Helper column (column D in the example below)



A

B

C

D

E

F

G

1

name​

property​

checking​

HELPER​

criteria​

result (based on "name")​

2

robert​

pc​

yes​

yes​

yes​

2​

3

monitor​

yes​

no​

1​

4

david​

keyboard​

no​

no​

blank​

1​

5

alfie​

notebook​

blank​

6

lcd​

blank​

criteria​

result (based on "property")​

7

mouse​

blank​

yes​

4​

8

zidan​

rose​

yes​

yes​

no​

1​

9

glass​

yes​

blank​

3​

<TBODY>
</TBODY>


Formula in D2 (Helper)
=IF(A2<>"",IF(C2<>"",C2,"blank"),D1)

Formula in G2
=COUNTIFS($A$2:$A$9,"?*",$D$2:$D$9,F2)
copy down till G4

Formula in G7
=COUNTIFS($B$2:$B$9,"?*",$D$2:$D$9,F2)
copy down till G9

M.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
no, as criteria in column C (yes,no,blank). if criteria in col.c contains "yes" in col. b must be 4 item consists of pc,monitor,rose,glass
 
Upvote 0
no, as criteria in column C (yes,no,blank). if criteria in col.c contains "yes" in col. b must be 4 item consists of pc,monitor,rose,glass

namepropertychecking
robertpcyes
monitor
davidkeyboardno
alfienotebook
lcd
mouse
zidanroseyes
glass

<COLGROUP><COL style="WIDTH: 71pt; mso-width-source: userset; mso-width-alt: 3384" width=95><COL style="WIDTH: 102pt; mso-width-source: userset; mso-width-alt: 4835" width=136><COL style="WIDTH: 83pt; mso-width-source: userset; mso-width-alt: 3925" width=110><TBODY>
</TBODY>

This is really exaspareting. Column C we have 2 yes items. How do we get 4 we also look at column B?
 
Upvote 0
at the first, i also confused too but reply from Marcelo (OP #21) make me know that in this case we need helper column..
it's exactly that i want but in this case can we do without helper column.It's possible?
 
Upvote 0
hi Aladin, of course..

why you give me the same link in this forum, have you missing?
 
Upvote 0
... can we do without helper column.It's possible?
Using standard Excel functions I can't see a feasible way. I don't see a problem with a helper column and it can always be hidden if required.

However, if you really didn't want a helper column, you could consider a user-defined function like this. To implement ..

1. Right click the sheet name tab and choose "View Code".

2. In the Visual Basic window use the menu to Insert|Module

3. Copy and Paste the code below into the main right hand pane that opens at step 2.

4. Close the Visual Basic window.

5. Enter the formulas as shown in the screen shot below and copy down.

6. If using Excel 2007 or later your workbook will need to be saved as a macro-enabled file (*.xlsm)
Rich (BB code):
Function CritCount(rCrit As Range, sCrit As String, lBasedOnColumn As Long) As Long
  Dim a
  Dim i As Long, k As Long

  a = rCrit.Value
  For i = 1 To UBound(a, 1)
    If a(i, 3) = vbNullString Then
      If a(i, 1) = vbNullString Then
        a(i, 3) = a(i - 1, 3)
      Else
        a(i, 3) = "blank"
      End If
    End If
    If a(i, lBasedOnColumn) <> vbNullString And a(i, 3) = LCase(sCrit) Then k = k + 1
  Next i
  CritCount = k
End Function


Excel Workbook
ABCDEFG
1namepropertycheckingcriteriaresult (based on "name")
2robertpcyesyes2
3monitorno1
4davidkeyboardnoblank1
5alfienotebook
6lcdcriteriaresult (based on "property")
7mouseyes4
8zidanroseyesno1
9glassblank3
Count
 
Upvote 0
hi Peter, thanks you for your feedback...

You make a difference, by the way, it's awesome...
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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