Count with interval conditional

ibmy

Board Regular
Joined
Mar 4, 2020
Messages
134
Office Version
  1. 2016
Platform
  1. Windows
Column A / Column B // Column C

0 / 0.1 // (1)
0 / -0.1 // (2)
0 / 0.1 // (3)
0 / -0.1 // (4)
0 / 0.1 // (5)
-0.1 / 0 // (1)
0.1 / 0 // (2)
0.1 / 0 // (1)
0.7 / 0 //
-0.1 / 0.5 //


Rule:
1) Starting value is 0.1 or -0.1
> Exist at column A or B
2) Other column must 0
3) The count start if next row is -0.1 (starting 0.1) and 0.1 (starting from -0.1).
> The count continues 0.1 -> -0.1 -> 0.1 ........ as long as its not break all above rule..

Break of Rule:
1) Break if other column is not 0
2) Break if it not follow by 0.1 / -0.1

Example of break rule:

1) The count reset (not continue) when not follow 0.1 -> -0.1 -> 0.1 ......

-0.1/ 0 // (1)
0.1 / 0 // (2)
0.1 / 0 // (1)
0.1 / 0 // (1)
0 / -0.1 // (1)
0 / -0.1 // (1)

2) No count when follow by other number than 0.1 / -0.1

-0.1/ 0 // (1)
0.1 / 0 // (2)
0.7 / 0 //

3) No count when other column is not 0.

-0.1 / 0 // (1)
0.1 / 0 // (2)
-0.1 / 0.5 //

p/s:
If 2 column (A&B) is hard to formula at the same time, then formula for 1 column will do. I can do 1 column at one time. I test column A first then column B ( I will apply formula to count at column A first then column B).

Thanks.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I suspect that there's a shorter formula, but I got tied up in knots trying to find one. So I just went back to basics and came up with:


Book1
ABC
1Column AColumn BColumn C
200.11
30-0.12
400.13
50-0.14
600.15
7-0.101
80.102
90.101
100.70 
11-0.10.5 
120.101
13-0.102
140.103
15-0.12 
160.101
170.101
180.101
19-0.102
2000.11
210-0.12
220-0.11
Sheet20
Cell Formulas
RangeFormula
C2:C22C2=IF(AND(A2=0,A1=0,B2=0.1,B1=-0.1),N(C1)+1,IF(AND(A2=0,A1=0,B2=-0.1,B1=0.1),N(C1)+1,IF(AND(A2=0.1,A1=-0.1,B2=0,B1=0),N(C1)+1,IF(AND(A2=-0.1,A1=0.1,B2=0,B1=0),N(C1)+1,IF(AND(COUNTIF(A2:B2,0)=1,ABS(A2+B2)=0.1),1,"")))))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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