DRSteele
Well-known Member
- Joined
- Mar 31, 2015
- Messages
- 2,652
- Office Version
- 365
- Platform
- Windows
I wonder if someone can please help me understand how the function FREQUENCY operates here.
This algorithm counts the current streak of ONs and OFFs, counts the longest streaks of ONs and counts the longest streaks of OFFs. I just don't know how nor why it works.
Specifically, what goes on here? {=FREQUENCY(IF(B$5:B$14=1,ROW(B$5:B$14)),IF(B$5:B$14=0,ROW(B$5:B$14)))} reports this: {0;2;0;5}
Excel 2012
<colgroup><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FFF2CC"]Current Streak[/TD]
[TD="bgcolor: #FFF2CC"]On Streak[/TD]
[TD="bgcolor: #FFF2CC"]Off Streak[/TD]
[TD="align: center"]2[/TD]
[TD="bgcolor: #E2EFDA"]on 5[/TD]
[TD="bgcolor: #E2EFDA, align: right"]5[/TD]
[TD="bgcolor: #E2EFDA, align: right"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]11[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]12[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]13[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]14[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
</tbody>
[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10, bgcolor: #DAE7F5"]A2[/TH]
[TD="align: left"]{=LOOKUP(INDEX(B$5:B$14,COUNT(B$5:B$14)),{0,1},{"off","on"})&" "&
IF(COUNTIF(B$5:B$14,B$5)=COUNT(B$5:B$14),COUNT(B$5:B$14),MAX((B$5:B$14<>"")*ROW(B$5:B$14))-MAX((B$5:B$14<>INDEX(B$5:B$14,COUNT(B$5:B$14)))*(B$5:B$14<>"")*ROW(B$5:B$14)))}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]{=MAX(FREQUENCY(IF(B$5:B$14=1,ROW(B$5:B$14)),IF(B$5:B$14=0,ROW(B$5:B$14))))}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]C2[/TH]
[TD="align: left"]{=MAX(FREQUENCY(IF(B$5:B$14=0,ROW(B$5:B$14)),IF(B$5:B$14=1,ROW(B$5:B$14))))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
This algorithm counts the current streak of ONs and OFFs, counts the longest streaks of ONs and counts the longest streaks of OFFs. I just don't know how nor why it works.
Specifically, what goes on here? {=FREQUENCY(IF(B$5:B$14=1,ROW(B$5:B$14)),IF(B$5:B$14=0,ROW(B$5:B$14)))} reports this: {0;2;0;5}
Excel 2012
A | B | C | |
---|---|---|---|
Day | on/off | ||
<colgroup><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FFF2CC"]Current Streak[/TD]
[TD="bgcolor: #FFF2CC"]On Streak[/TD]
[TD="bgcolor: #FFF2CC"]Off Streak[/TD]
[TD="align: center"]2[/TD]
[TD="bgcolor: #E2EFDA"]on 5[/TD]
[TD="bgcolor: #E2EFDA, align: right"]5[/TD]
[TD="bgcolor: #E2EFDA, align: right"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]11[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]12[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]13[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]14[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
</tbody>
Sheet2
[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10, bgcolor: #DAE7F5"]A2[/TH]
[TD="align: left"]{=LOOKUP(INDEX(B$5:B$14,COUNT(B$5:B$14)),{0,1},{"off","on"})&" "&
IF(COUNTIF(B$5:B$14,B$5)=COUNT(B$5:B$14),COUNT(B$5:B$14),MAX((B$5:B$14<>"")*ROW(B$5:B$14))-MAX((B$5:B$14<>INDEX(B$5:B$14,COUNT(B$5:B$14)))*(B$5:B$14<>"")*ROW(B$5:B$14)))}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]{=MAX(FREQUENCY(IF(B$5:B$14=1,ROW(B$5:B$14)),IF(B$5:B$14=0,ROW(B$5:B$14))))}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]C2[/TH]
[TD="align: left"]{=MAX(FREQUENCY(IF(B$5:B$14=0,ROW(B$5:B$14)),IF(B$5:B$14=1,ROW(B$5:B$14))))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]