Countif Binary Strings w/ "1" in Position

Excel18

New Member
Joined
Jul 12, 2016
Messages
5
Hello,
I am having a problem with counting specific binary strings (with the value of "1" in a specific position) and was hoping for some advice.

I am importing data into Excel and converting each point to binary (I think this is the best way).

An example: Event 1 has the value 001. Event 3 has the value 100. When they occur simultaneously, the value is 101.

I am looking for a way to count each time an event occurs, either solo or simultaneously with other events. So, in the above example, I want to count whenever Event 1 occurs (and the string appears ??1).

I was hoping to create an equation which counted whenever the third digit in the string equals 1. I was thinking of using an equation such as
COUNTIF(Range,MID(Cell,3,1)=1)

or

COUNTIF(Cell,"??1")

However, neither of these work and I am unsure of how to proceed. Does anyone have any advice?
Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try:

=SUMPRODUCT(--(RIGHT(Range,1)="1"))

where Range is the address of the range you want to count (e.g. A1:A100).
 
Upvote 0
Hi,

For some reason, a simple COUNTIF works for me whether the cell is formatted as Custom 000, or Text:


Excel 2010
ABCDEFG
1001Count of001Count of
210000131000013
300101040010104
401010030101003
5010010
6100100
7010010
8100100
9010010
10001001
11
12Formatted Custom 000Formatted as Text
13TRUEFALSE
Sheet1
Cell Formulas
RangeFormula
C2=COUNTIF(A$1:A$10,1)
C3=COUNTIF(A$1:A$10,10)
C4=COUNTIF(A$1:A$10,100)
G2=COUNTIF(E$1:E$10,1)
G3=COUNTIF(E$1:E$10,10)
G4=COUNTIF(E$1:E$10,100)
A13=ISNUMBER(A1)
E13=ISNUMBER(E1)
 
Last edited:
Upvote 0
For the COUNTIF solution, you don't have any mixed events, such as 101.
 
Last edited:
Upvote 0
For the COUNTIF solution, you don't have any mixed events, such as 101.

Here, not sure why it works (for the Text column):


Excel 2010
ABCDEFG
1001Count of001Count of
210000121000012
300101030010103
411110021111002
501010110101011
610111121011112
7010010
8100100
9010010
10111111
11
12Formatted Custom 000Formatted as Text
13TRUEFALSE
Sheet1
Cell Formulas
RangeFormula
C2=COUNTIF(A$1:A$10,1)
C3=COUNTIF(A$1:A$10,10)
C4=COUNTIF(A$1:A$10,100)
C5=COUNTIF(A$1:A$10,101)
C6=COUNTIF(A$1:A$10,111)
G2=COUNTIF(E$1:E$10,1)
G3=COUNTIF(E$1:E$10,10)
G4=COUNTIF(E$1:E$10,100)
G5=COUNTIF(E$1:E$10,101)
G6=COUNTIF(E$1:E$10,111)
A13=ISNUMBER(A1)
E13=ISNUMBER(E1)
 
Last edited:
Upvote 0
Hello,
I am having a problem with counting specific binary strings (with the value of "1" in a specific position) and was hoping for some advice.

I am importing data into Excel and converting each point to binary (I think this is the best way).

An example: Event 1 has the value 001. Event 3 has the value 100. When they occur simultaneously, the value is 101.

I am looking for a way to count each time an event occurs, either solo or simultaneously with other events. So, in the above example, I want to count whenever Event 1 occurs (and the string appears ??1).

I was hoping to create an equation which counted whenever the third digit in the string equals 1. I was thinking of using an equation such as
COUNTIF(Range,MID(Cell,3,1)=1)

or

COUNTIF(Cell,"??1")

However, neither of these work and I am unsure of how to proceed. Does anyone have any advice?
Thanks.

Maybe you should proceed to create a sample along with the specs what to count and the associated count.

It's important to know the nature of your input. For example:

'001

in A2 is text, that is, =ISNUMBER(A2) >> FALSE.

If A2 houses 1 and =ISNUMBER(A2) >> TRUE, formatting A2 to display 001 doesn't make A2 text.
 
Upvote 0
Here, not sure why it works (for the Text column):

The op wanted to count when say event 1 occurred, so for 001 and 101, it should count 2 for this because 1 is in the rightmost column both times, not as 2 different results but 1.
 
Upvote 0

Forum statistics

Threads
1,215,128
Messages
6,123,204
Members
449,090
Latest member
bes000

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