Looking for a better and worse sequence

Marvo

Board Regular
Joined
Nov 27, 2023
Messages
155
Office Version
  1. 2021
Platform
  1. Windows
Hi All, I have a large workbook that involves all the matches of Northampton Town FC. On the worksheet I have a cell (W1) that you can put however many matches you like and you can see how many points have been gained from those most recent matches (current form). This works fine.
In W5 I have for League matches only
=SUMPRODUCT(COUNTIFS(INDEX(ALL!K:K,LARGE(INDEX(ROW(ALL!$K:$K)*(ALL!$K:$K<>"")*(ALL!$J:$J=$V$5),),$W$1)):ALL!$K$9999,{"W","D"},INDEX(ALL!J:J,LARGE(INDEX(ROW(ALL!$K:$K)*(ALL!$K:$K<>"")*(ALL!$J:$J=$V$5),),$W$1)):ALL!$J$9999,$V$5),{3,1})
In W7 I have for all matches
=SUMPRODUCT(COUNTIFS(INDEX(ALL!K:K,LARGE(INDEX(ROW(ALL!$K:$K)*(ALL!$K:$K<>""),),$W$1)):ALL!$K$9999,{"W","D"},INDEX(ALL!J:J,LARGE(INDEX(ROW(ALL!$K:$K)*(ALL!$K:$K<>""),),$W$1)):ALL!$J$9999,$V$5),{3,1})

Now somebody several years ago placed VBA on the worksheet that would look back to find the last time the most recent sequence was either better or worse (and other things). This was very useful but sadly it went awry and I don't don't understand VBA and now its disappeared altogether. So what I'm wondering is whether I could put a formula in a cell to do the same job?

So just to reiterate, if the club in its last 5 games had just won its last 4 league games and drawn another = 13pts, the formula would look for the previous sequence of 5 games when that was bettered (that could only be 5 wins).
Alternatively if the club was in a slump and in its last 5 games it had lost 4 and drawn 1 = 1pt, it would look for the last time the club did worse than that which would have to be 5 sequential defeats = 0pts.

Now all this makes sense to me when I read it back but I'm guessing it wont make any sense to anyone else. My question is, it it possible to do this with a formula?

example.JPG
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I'd put a couple of helper columns in your "ALL" worksheet, along these lines:

ABCDEFG
1Seq Length (N)5
2PointsPoints
3GoalsGoalsLeagueAll
4DateFixtureForAgainstPointsSequenceSequence
517 Feb 2024FA Cup120--
624 Feb 2024League103--
72 Mar 2024FA Cup120--
89 Mar 2024League303--
916 Mar 2024League001-7
1023 Mar 2024League130-7
1130 Mar 2024League02074
126 Apr 2024FA Cup001-5
1313 Apr 2024League14042
1420 Apr 2024League22122
1527 Apr 2024League01012
164 May 2024Charity323-5
1711 May 2024League11125
1818 May 2024League30358
Sheet1
Cell Formulas
RangeFormula
E5:E18E5=(C5=D5)+3*(C5>D5)
F5:F18F5=LET(p,TAKE(FILTER(E$5:E5,B$5:B5="League",1),-N),IF(AND(B5="League",ROWS(p)>=N),SUM(p),"-"))
G5:G18G5=IF(ROWS(C$5:C5)>=N,SUM(E1:E5),"-")
Named Ranges
NameRefers ToCells
N=Sheet1!$B$1F5:G18

Then it's relatively simple to write additional formulae to identify the date of the previous better/worse points sequence.

But please let us know first whether these formulae work for you, i.e. whether you have access to the LET, TAKE and FILTER functions?

If not, the formulae can also be rewritten for older versions of Excel.
 
Upvote 0
Many thanks for the reply, I'll look at it in the morning, see how it goes.

I have the latest excel (I think) but not 365.
 
Upvote 0
I'll just add I used to have several helper columns but with over 5,000 rows it really slowed my workbook down.
 
Upvote 0
Hi. Sorry for the delay, finally got time to get back to this. This is as far as I've got.

I already had a column (K) with the result in, either W, D or L so it was relatively easy using SWITCH to construct the two helper columns with points from the games.

ALL GAMES (Column AF)
=SWITCH(K2,"W",3,"D",1,"L","")

LEAGUE GAMES (Column AG)
=IF(J2="League",SWITCH(K2,"W",3,"D",1,""),"")

I don't know where to go from this point in regard the best and worst sequences. Sorry, I don't understand the formula's.
excel.JPG
 
Upvote 0
Along these lines perhaps?

ABCDEFG
1Seq Length (N)5
2PointsPoints
3GoalsGoalsLeagueAll
4DateFixtureForAgainstPointsSequenceSequence
517 Feb 2024FA Cup120--
624 Feb 2024League103--
72 Mar 2024FA Cup120--
89 Mar 2024League303--
916 Mar 2024League001-7
1023 Mar 2024League130-7
1130 Mar 2024League02074
126 Apr 2024FA Cup001-5
1313 Apr 2024League14042
1420 Apr 2024League22122
1527 Apr 2024League01012
164 May 2024Charity323-5
1711 May 2024League11125
1818 May 2024League30358
19
20
21LeagueALL
22Test date9 May 20249 May 2024
23Latest available seq27 Apr 20244 May 2024
24Points15
25Previous equal or worse#N/A27 Apr 2024
26Previous better20 Apr 202423 Mar 2024
Sheet1
Cell Formulas
RangeFormula
E5:E18E5=(C5=D5)+3*(C5>D5)
F5:F18F5=LET(p,TAKE(FILTER(E$5:E5,B$5:B5="League",1),-N),IF(AND(B5="League",ROWS(p)>=N),SUM(p),"-"))
G5:G18G5=LET(p,TAKE(E$5:E5,-N),IF(ROWS(p)>=N,SUM(p),"-"))
B23B23=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<=B22)*(F5:F18<>"-")),-1),#N/A)
C23C23=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<=C22)*(G5:G18<>"-")),-1),#N/A)
B24:C24B24=XLOOKUP(B23,$A5:$A18,F5:F18)
B25B25=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<B23)*(F5:F18<=B24)*(F5:F18<>"-")*(B5:B18="League")),-1),#N/A)
C25C25=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<C23)*(G5:G18<=C24)*(G5:G18<>"-")),-1),#N/A)
B26B26=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<B23)*(F5:F18>B24)*(F5:F18<>"-")*(B5:B18="League")),-1),#N/A)
C26C26=IFERROR(TAKE(FILTER(A5:A18,(A5:A18<C23)*(G5:G18>C24)*(G5:G18<>"-")),-1),#N/A)
Named Ranges
NameRefers ToCells
N=Sheet1!$B$1F5:G18
 
Upvote 0
@StephenCrump
Stephen, I don't think the user will have TAKE in version 2021
Thanks Peter, I think you're right.
But please let us know first whether these formulae work for you, i.e. whether you have access to the LET, TAKE and FILTER functions?
I was being a bit lazy and asking the OP to let us know.

Let's see what does and doesn't work, and modify accordingly.
 
Upvote 0
I do apologise, because I've recently updated from 2016 to 2021 (the excel edition is 2018) I thought I'd got the latest. I have got a lot of new functions that I didn't have previously, like LET, but I do not have the TAKE function. Again, please accept my apologies.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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