Count a number just the first time it appears in each string.

Marvo

Board Regular
Joined
Nov 27, 2023
Messages
182
Office Version
  1. 2021
Platform
  1. Windows
In the image B2 copied down is =IF(($A2="League")*($B2="H"),IF($C2="W",SUM(1,D1),0),N(D1))

It's counting consecutive winning home league games. The result is 12.

However if you put a formula at the bottom of Column D, =COUNTIF(D2:D34,E14), it would give you a result of 4. But of course you've only reached 12 once.

Is there another way of asking the question to get a result of 1, or if further down the column there was another run of 13, a result of 2?

I can't think of a way.

Any help appreciated.
 

Attachments

  • Mr Excel.JPG
    Mr Excel.JPG
    79.2 KB · Views: 32

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
That's fabulous Stephen, certainly works in the example given, now to try it in the big workbook. Thank you very much.
 
Upvote 0
Hi again Stephen, couldn't get it to work in the larger workbook.

I've entered =IF(C25="","",COUNTIFS(ALL!$J2:$J5558,A25,ALL!$B2:$B5558,B25,ALL!$BB$2:$BB$5558,C25))

C25 = 12
A25 = League
B25 = H

There are two instances of 12 in the column and they should only count as 1 as they are in the same string, however the result I'm getting is Zero. Can you see where I've gone wrong please?
 
Upvote 0
what about:
Excel Formula:
=COUNTIFS(D2:D34,E14,D1:D33,E14-1)
 
Upvote 0
I'd made a mistake in the formula Stephen gave me. Having rectified it, the result I'm getting is 2. There are indeed 2 instances of 12 in the column bitbthey are part of the same string. The result I'm after is 1.
 
Upvote 0
There are two instances of 12 in the column and they should only count as 1 as they are in the same string, however the result I'm getting is Zero.

I'd made a mistake in the formula Stephen gave me. Having rectified it, the result I'm getting is 2.

It's a little hard to know what's going on without seeing your layout. Can you post a sample using XL2BB - Excel Range to BBCode?
 
Upvote 0
Okay, its sorted, schoolboy error. Thanks very much, your formula does indeed work Stephen. Much obliged and sorry for the misunderstanding.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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