I'm having trouble getting my league table to calculate based on x number of games. I want to come up with a solution that is based in one cell as much as possible — making use of the new dynamic array functions. Please don't suggest using a pivot table, Power Query or helper columns.
You'll see all the matches are stored in the 'Database' worksheet. The teams are featured in 'Teams' and the seasons they have participated in are represented by a 1. You'll notice there are a number of tables in the 'Table' worksheet. These are just from where I've experimented with formulas to try and gain an inkling of how to go about solving this problem.
So let me just explain the breakdown of what needs to be included when querying the table in the 'Database' worksheet:
• Only played games — represented by a 1.
• Only games from the season selected in cell H2 in the ‘Table’ worksheet.
• Only games that have a date that is less than or equal to the nth smallest date. This is based on the k number specified in cell F2. For example, if this value is 10, then the first 10 games should be considered. Remember: this includes home*AND*away games, so the formula has to look at both columns. I know I have used COUNTIFS and SUMIFS, but they don't work with this scenario, as the range can only be a single column. I have tried conditional SUMPRODUCT and AGGREGATE alternatives, however, they do not seem to handle spilled ranges like 'Teams!B2#'.
If anyone has any possible workarounds for this it would be much appreciated.
Please see the attached workbook.
Bookmarks