3 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Excel dynamic array challenge: sequentially filtering rows by chaining winners to their next match

Excel version: 365

For quite some time now I've been working on a silly project on my spare time. It's not something serious, and my issue is not even critical to what I'm trying to do. It is basically a compilation of (almost) all international football (soccer) matches.

You can download the full workbook here to play around with it.

Now here's my situation:

Consider that I have a range comprised of 6 columns and several rows, named AllTimeMatches

Column 1 is the date of a football match.

Column 2 is the home team.

Column 3 is the home team score.

Column 4 is just a separator.

Column 5 is the away team score.

Column 6 is the away team.

I've already used LET(r,AllTimeLeagueMatches,FILTER(r,INDEX(r,,3)<>INDEX(r,,5))) to do away with matches that ended in a draw, because for this part of the project I'm only looking at matches with a win/loss result.

What I want now is to look on a row by row basis for the next match by the winner of the previous match.

Example: I'm intentionally omitting the column 1 values because they are irrelevant for what I need. Let's assume the range has these rows:

  1. Northern Ireland 7 x 2 Wales
  2. England 6 x 1 Northern Ireland
  3. Wales 3 x 4 Scotland
  4. Scotland 2 x 1 Northern Ireland
  5. England 2 x 1 Scotland
  6. Canada 1 x 4 United States
  7. Canada 1 x 2 United States
  8. Canada 1 x 2 United States
  9. Scotland 5 x 1 Canada
  10. Northern Ireland 0 x 2 England

In this example, because Northern Ireland won the first match, you need to look for the next match played by Northern Ireland.

So, Northern Ireland plays against England in row 2 and loses. Because England won this one, you'll look for the next match played by England.

England's next match is in row 5, so rows 3 and 4 will not be shown.

England wins again in row 5, so you continue looking for England.

Every time the winner changes, you will look for the next match played by the winner until the last row of the range, or until there are no more matches played by the current winner, whichever comes first.

In this example, the result would be:

Northern Ireland 7 x 2 Wales

England 6 x 1 Northern Ireland

England 2 x 1 Scotland

Northern Ireland 0 x 2 England

Is it doable? I've already asked AI. It says it is doable, but none of their proposed formulas work, and I can't figure it out with my current knowledge.

Again, no need to burn your neurons with this, but if something figures this out, I'd love it.

If my query is not clear, just ask, I'll be more than happy to clarify.

submitted by /u/VirtualS1nn3r
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article

Tagged with

#Excel alternatives for data analysis
#natural language processing for spreadsheets
#generative AI for data analysis
#row zero
#rows.com
#financial modeling with spreadsheets
#real-time data collaboration
#real-time collaboration
#Excel compatibility
#Excel alternatives
#matches
#Excel
#football
#soccer
#dynamic array
#next match
#filtering
#score
#win/loss result
#winner