SUM/COUNT of value 1 at the end of set

ibmy

Board Regular
Joined
Mar 4, 2020
Messages
103
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Data contain just 2 value which are 1 and 0.
01 set.xlsx
AB
1DataResult
20
311
40
50
61
71
813
90
101
1112
120
130
1411
150
160
170
Sheet3

Thanks advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Would you like to tell us what you actually want to do ??
Maybe like
Excel Formula:
=COUNTIF(A2:A17,1)
 
Upvote 0
@Michael M
Sample of 50-100k row set data:
01 set.xlsx
ABCDEFG
3508.10.2021 05:02:52.264 GMT+08001.155631.15531011 
3608.10.2021 05:03:04.109 GMT+08001.155631.155300  
3708.10.2021 05:03:04.214 GMT+08001.155611.155331111
3808.10.2021 05:03:04.371 GMT+08001.155631.15532112 
3908.10.2021 05:03:14.825 GMT+08001.155631.1553501 3
4008.10.2021 05:03:23.223 GMT+08001.155621.15535101 
4108.10.2021 05:03:28.842 GMT+08001.155621.1553701 1
4208.10.2021 05:03:35.654 GMT+08001.155621.1553901 2
4308.10.2021 05:03:41.993 GMT+08001.155581.15539101 
4408.10.2021 05:03:45.004 GMT+08001.155581.1553801 1
4508.10.2021 05:04:11.278 GMT+08001.155581.1553701 2
4608.10.2021 05:04:42.262 GMT+08001.155621.15537101 
4708.10.2021 05:04:50.305 GMT+08001.155621.1553901 1
4808.10.2021 05:04:50.515 GMT+08001.155621.1553801  
4908.10.2021 05:04:51.255 GMT+08001.15561.15539111 
5008.10.2021 05:04:55.111 GMT+08001.155611.15537112 
Sheet1
Cell Formulas
RangeFormula
D35:E50D35=IF(B35<>B34,1,0)
F35:G50F35=IF(AND(D34=0,D35<>0),D35,IF(AND(D36=0,D35<>0),ROW(F35)-IFERROR(MATCH(1E+100,F$2:F34),0),""))

The actual data are Column A,B and C
Then I would like analyze the data :
As formula Column D and E for Column B and C respectively. =IF(B3<>B2,1,0) and =IF(C3<>C2,1,0)
Then I use the formula in Column F and G which I ask 1 year ago Show Starting (Number 1) and Max only
The formula works great, then I want to achieved show starting start of set and max but now I no need anymore show starting start of set.
I tried to modify he formula to meet my needs for current analysis but did not work.
Hopefully, with simpler formula, the formula run faster on my old laptop which heavy to handle the set of data which contain 50-100k row data.
 
Last edited:
Upvote 0
Sample of 50-100k row set data:
With that much data, I would suggest a macro. With post #3 I didn't really understand what part, if any you wanted help with but for the layout in post #1, try this

VBA Code:
Sub Result()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
  
  a = Range("A1", Range("A" & Rows.Count).End(xlUp).Offset(1)).Value
  ReDim b(1 To UBound(a), 1 To 1)
  b(1, 1) = "Result"
  For i = 2 To UBound(a)
    If a(i, 1) = 1 Then
      k = k + 1
    Else
      If a(i - 1, 1) = 1 Then
        b(i - 1, 1) = k
        k = 0
      End If
    End If
  Next i
  Range("B1").Resize(UBound(b)).Value = b
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,523
Messages
6,120,031
Members
448,940
Latest member
mdusw

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