Calculating current streaks with a certain criteria

speedychaz94

New Member
Joined
Dec 7, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello to whoever is reading this.

I have joined and became a member. I have never asked a question on a forum before as I am usually able to find things myself. However, this time I am really struggling so I have concluded that I need help. I am no expert at excel but I have been learning quite a lot over the past month and I have been enjoying it.
So....my question.
I have created a large spreadsheet with over 2000 entries on UFC fighters (I am a bit of a UFC nerd). On my sheet I have the outcomes of each athlete's fights. I display their results on a scoring criteria (3=win via stoppage, 2=win via decision, 1=draw, 0=No contest & -1=loss). I have already calculated the main stats (e.g. no of wins/losses/draws) but I am struggling to calculate current streak of wins via stoppage (current finish streak or 3's). I assume the formula will include INDEX & MATCH but I am not 100% sure how to put it together. I would really appreciate some help. I have attached a sample of my spreadsheet. Or for those that can't access it....

ABCDEFGHIJKLMNOPQRSTU
1Fighter Name1st Fight2nd Fight3rd Fight4th Fight5th Fight6th Fight7th Fight8th Fight9th Fight10th FightNo of AppWinsFinishesLosses/NCDrawsPointsHighest Unbeaten/SCurrent UnB/SHighest Finish/SCurrent F/S
2Jimmy
2​
2​
-1​
0​
3​
2​
3​
7​
5​
2​
2​
0​
11​
3​
4​
1​
?
3Bob
-1​
-1​
2​
2​
2​
3​
6​
4​
1​
2​
0​
7​
4​
4​
1​
?
4Gary
2​
3​
3​
3​
2​
2​
-1​
3​
8​
7​
4​
1​
0​
17​
7​
1​
3​
?
5Ryan
3​
3​
1​
2​
2​
3​
3​
7​
6​
4​
0​
1​
17​
4​
7​
2​
?
6Lewis
3​
-1​
-1​
-1​
-1​
5​
1​
1​
4​
0​
-1​
2​
0​
1​
?
7Randy
-1​
2​
2​
1​
3​
3​
3​
1​
-1​
9​
5​
3​
2​
2​
13​
3​
0​
3​
?
8Joe
3​
3​
-1​
-1​
2​
2​
3​
7​
5​
3​
2​
0​
11​
3​
3​
2​
?
9Doug
3​
3​
1​
2​
3​
2​
3​
-1​
2​
9​
7​
4​
1​
1​
18​
4​
1​
2​
?
10Frank
3​
-1​
-1​
2​
3​
0​
1​
3​
3​
3​
10​
6​
5​
3​
1​
16​
3​
7​
3​
?


So again, I need to calculate the current streak of 3's (wins via stoppage).

The results in column U2, for current finish streak should be U2=1, U3=1, U4=1, U5=2, U6=0, U7=0, U8=1, U9=0, U10=3.

*Remember not every fighter has the same number of fights which I believe makes this formula a bit more complicated.


Thanks in advanced.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about this?

Book2
ABCDEFGHIJKLMNOPQRSTU
1Fighter Name1st Fight2nd Fight3rd Fight4th Fight5th Fight6th Fight7th Fight8th Fight9th Fight10th FightNo of AppWinsFinishesLosses/NCDrawsPointsHighest Unbeaten/SCurrent UnB/SHighest Finish/SCurrent F/S
2Jimmy22-1032375220113411
3Bob-1-122236412074411
4Gary233322-1387410177131
5Ryan331223376401174722
6Lewis3-1-1-1-151140-12010
7Randy-12213331-195322133030
8Joe33-1-122375320113321
9Doug3312323-1297411184120
10Frank3-1-12301333106531163733
Sheet3
Cell Formulas
RangeFormula
U2:U10U2=COUNTIF(INDIRECT(ADDRESS(ROW(),MATCH(2,1/(B2:K2<3),1)+2)&":"&"K"&ROW()),3)
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Solution
A way using VBA or Power Query too.

Book2
ABCDEFGHIJKLMNOPQRSTVW
1Fighter Name1st Fight2nd Fight3rd Fight4th Fight5th Fight6th Fight7th Fight8th Fight9th Fight10th FightNo of AppWinsFinishesLosses/NCDrawsPointsHighest Unbeaten/SCurrent UnB/SHighest Finish/SVBA WINCurrent F/S
2Jimmy22-10323752201134111
3Bob-1-1222364120744111
4Gary233322-13874101771311
5Ryan3312233764011747222
6Lewis3-1-1-1-151140-120100
7Randy-12213331-1953221330300
8Joe33-1-1223753201133211
9Doug3312323-12974111841200
10Frank3-1-123013331065311637333
Sheet3
Cell Formulas
RangeFormula
V2:V10V2=WINS(B2:K2)


VBA Code:
Function WINS(r As Range) As Integer
Dim AR() As Variant: AR = r.Value2

For i = UBound(AR, 2) To LBound(AR) Step -1
    If AR(1, i) <> "" Then
        If AR(1, i) = 3 Then WINS = WINS + 1 Else Exit For
    End If
Next i
End Function

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Index = Table.AddIndexColumn(Source, "Index", 0, 1),
    RC = Table.SelectColumns(Index,{"1st Fight", "2nd Fight", "3rd Fight", "4th Fight", "5th Fight", "6th Fight", "7th Fight", "8th Fight", "9th Fight", "10th Fight", "Index"}),
    Unpivot = Table.UnpivotOtherColumns(RC, {"Index"}, "Attribute", "Value"),
    NoBlank = Table.SelectRows(Unpivot, each ([Value] <> "")),
    X = Table.TransformColumns(NoBlank,{{"Value", each if _ = 3 then "X" else "N"}}),
    Group0 = Table.Group(X, {"Index", "Value"}, {{"Count", each Table.AddIndexColumn(_, "subsetIndex",1,1), type table}},GroupKind.Local),
    Group1 = Table.Group(Group0, {"Index"}, {{"Count", each _, type table}}),
    Last = Table.TransformColumns(Group1,{{"Count", each Table.Last(_)}}),
    Expand = Table.ExpandRecordColumn(Last, "Count", {"Value", "Count"}, {"Value", "Count.1"}),
    Current = Table.AddColumn(Expand, "Current F/S", each if [Value]= "N" then 0 else Table.RowCount([Count.1])),
    SC = Table.SelectColumns(Current,{"Current F/S"})
in
    SC
 
Upvote 0
How about this?

Book2
ABCDEFGHIJKLMNOPQRSTU
1Fighter Name1st Fight2nd Fight3rd Fight4th Fight5th Fight6th Fight7th Fight8th Fight9th Fight10th FightNo of AppWinsFinishesLosses/NCDrawsPointsHighest Unbeaten/SCurrent UnB/SHighest Finish/SCurrent F/S
2Jimmy22-1032375220113411
3Bob-1-122236412074411
4Gary233322-1387410177131
5Ryan331223376401174722
6Lewis3-1-1-1-151140-12010
7Randy-12213331-195322133030
8Joe33-1-122375320113321
9Doug3312323-1297411184120
10Frank3-1-12301333106531163733
Sheet3
Cell Formulas
RangeFormula
U2:U10U2=COUNTIF(INDIRECT(ADDRESS(ROW(),MATCH(2,1/(B2:K2<3),1)+2)&":"&"K"&ROW()),3)
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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