How many times does an "x" occur before a "y"?

danzilla911

New Member
Joined
May 7, 2023
Messages
2
Office Version
  1. 365
Hi everyone,

I run a monthly bowling tournament and I want to find a way to calculate how many events each player has participated in since the last time they cashed. I have the devised following system to keep track of the results.

Key:
2 = Cashed
1 = Participated but did not cash
Blank = Did not participate

PlayerEvent 4Event 3Event 2Event 1Answer
A11
B1113
C210
D12221
E11222

The answers I calculated by hand are included in the far right column.

The basic calculation I am trying to figure out is how many "1's" appear before a "2" for each person. Blank cells do not count.

I am somewhat experienced in Excel but I cannot figure out a formula or even find another example of how to make this work. Any ideas would be greatly appreciated.

Thank you!

- Dan
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Welcome to the MrExcel forum!

I'm sure there's a better way, but try:

Book1
ABCDEFG
1PlayerEvent 4Event 3Event 2Event 1Answer
2A11
3B1113
4C210
5D12221
6E11222
Sheet2
Cell Formulas
RangeFormula
G2:G6G2=IFERROR(COUNTIF(A2:INDEX(B2:E2,MATCH(2,B2:E2,0)),1),SUM(B2:E2))
 
Upvote 0
Welcome to the MrExcel forum!

I'm sure there's a better way, but try:

Book1
ABCDEFG
1PlayerEvent 4Event 3Event 2Event 1Answer
2A11
3B1113
4C210
5D12221
6E11222
Sheet2
Cell Formulas
RangeFormula
G2:G6G2=IFERROR(COUNTIF(A2:INDEX(B2:E2,MATCH(2,B2:E2,0)),1),SUM(B2:E2))
I think you nailed it! Thanks alot. You saved the day!
 
Upvote 0
Welcome to the MrExcel board!

What about this way?

23 05 08.xlsm
ABCDEFG
1PlayerEvent 4Event 3Event 2Event 1Answer
2A11
3B1113
4C210
5D12221
6E11222
Count since cashed
Cell Formulas
RangeFormula
G2:G6G2=FIND(2,CONCAT(B2:E2,2))-1
 
Upvote 1

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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