You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Numbers, last 5 games football results

I have the results of several soccer leagues on a spreadsheet. What I want to do is count how many wins or draws in the last 5 games played for a given team.


Instructions on google for excel use the "LARGE" function with nested IF function. Since Numbers doesn't allow nesting in their LARGE function it's a problem. So is there another way using Number's MATCH or other functions?


I identify the team and league together, since I dont want results from various Cup competitions which are also sprinkled through the data.


Gary

Posted on Nov 7, 2021 2:20 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 7, 2021 6:05 PM

That is an array formula. The IF inside the LARGE function is making it act like "LARGEIF". There is no LARGEIF function so we have to improvise.


Here is a shot at it. It took two extra columns and it assumes the data is in chronological order. Hopefully it won't be too slow for 12,000 rows and trying to get the results for numerous teams. Numbers is not the speed demon Excel is when it comes to calculations. Excel is astonishingly fast. Numbers is not, though it has gotten better over the years. It works better for smaller datasets. You may find it too slow and may want to use Excel.



K2 is the team name.

K3 is the number of games you want the stats for (5, 10, 15, etc)


H2 =COUNTIF(B2:C$22,B2)

I2 =COUNTIF(B2:C$22,C2)

You will want to increase those ranges to whatever your last row is (vs row 22 in my example).

Copy/Paste to the rest of the cells in the columns.

These two columns are counting the number of games played by the teams on that row, counting down.


K4 ="Wins = "&COUNTIFS(H,"<="&K3,B,K2,F,"H")+COUNTIFS(I,"<="&K3,C,K2,F,"A")

K5 ="Losses = "&COUNTIFS(H,"<="&K3,B,K2,F,"A")+COUNTIFS(I,"<="&K3,C,K2,F,"H")

K6 ="Draws = "&COUNTIFS(H,"<="&K3,B,K2,F,"D")+COUNTIFS(I,"<="&K3,C,K2,F,"D")


You can adapt the formulas to your summary table.


You might want to try it in the data table first (i.e., using column K) and see how fast or slow it is. You can copy/paste cells K2:K6 repeatedly to other rows in column K to see how many it can do before it slows down.

6 replies
Question marked as Top-ranking reply

Nov 7, 2021 6:05 PM in response to Gary King

That is an array formula. The IF inside the LARGE function is making it act like "LARGEIF". There is no LARGEIF function so we have to improvise.


Here is a shot at it. It took two extra columns and it assumes the data is in chronological order. Hopefully it won't be too slow for 12,000 rows and trying to get the results for numerous teams. Numbers is not the speed demon Excel is when it comes to calculations. Excel is astonishingly fast. Numbers is not, though it has gotten better over the years. It works better for smaller datasets. You may find it too slow and may want to use Excel.



K2 is the team name.

K3 is the number of games you want the stats for (5, 10, 15, etc)


H2 =COUNTIF(B2:C$22,B2)

I2 =COUNTIF(B2:C$22,C2)

You will want to increase those ranges to whatever your last row is (vs row 22 in my example).

Copy/Paste to the rest of the cells in the columns.

These two columns are counting the number of games played by the teams on that row, counting down.


K4 ="Wins = "&COUNTIFS(H,"<="&K3,B,K2,F,"H")+COUNTIFS(I,"<="&K3,C,K2,F,"A")

K5 ="Losses = "&COUNTIFS(H,"<="&K3,B,K2,F,"A")+COUNTIFS(I,"<="&K3,C,K2,F,"H")

K6 ="Draws = "&COUNTIFS(H,"<="&K3,B,K2,F,"D")+COUNTIFS(I,"<="&K3,C,K2,F,"D")


You can adapt the formulas to your summary table.


You might want to try it in the data table first (i.e., using column K) and see how fast or slow it is. You can copy/paste cells K2:K6 repeatedly to other rows in column K to see how many it can do before it slows down.

Nov 7, 2021 4:14 PM in response to Badunit

Thank for replying. The excel guys have this formula:



This is a sheet populated from a main data sheet of 12,000 matches, look like this:


For example Legnica FC (Poland Division 1) on top line has had 5 draws, but from last 15 games. I'd like to see the numbers for last 5 or 10 games. Number's LARGE function doesnt accept IF function nested, so I have been unable to solve this. I know how to convert those dates in column 1 to numbers friendly dates, and LARGE doesnt have a problem with that.

Nov 7, 2021 3:39 PM in response to Gary King

More information needed. A screenshot of your table might be helpful. The Excel formula that worked in that table would also be handy to see. I suspect it was an Excel "array" formula because most of the "normal" formulas are a direct 1:1 import. It might be possible to replicate it or design a formula that does the same thing a different way or it might require a new column to do some calculating that an "array" formula does within the formula.

Nov 8, 2021 5:24 AM in response to Gary King

That would have taken a few seconds in Excel. I don't know how they do it so fast or why Numbers is many orders of magnitude slower. I have been trying to do a test right to see the speed difference for this particular problem but Numbers keeps crashing. I've been unable to extend it to 12,000 rows without it taking minutes "calculating" then crashing when I try to make changes.


In Excel I was able to extend the data to 12,000 rows. I edited the COUNTIF formulas in Row 2 to include all 12,000 rows then copy/pasted them all the way to row 12,000. It took 2 seconds to complete. Changing the team name in K2 provides instantaneous results.


In Numbers, I extended the table to 12,000 rows before editing the COUNTIF formulas so it filled down with the old formulas, generating error messages for all the invalid references. I am unable to delete them without it crashing the app. I tried deleting a few hundred at a time then a few thousand at a time, saving the document after each time, but after a few times it stopped letting me save my changes. In other words, it has failed and is going to crash. I've been at this an hour. I give up.


VERDICT: Use Excel or one of the Excel clones. Maybe Google Sheets can do it. Numbers is not up to the task. I enjoyed the challenge of converting the formula but Numbers cannot do 12,000 rows of this. It is highly disappointing when Excel can do it in 2 seconds.

Nov 8, 2021 8:52 PM in response to Badunit

I didn't have that kind of crashing problem. But did notice the formula would sometimes corrupt itself when copied to huge number of cells. I thought it was going ok, but then I notice irregularities with COUNTIFS, it can't count. Returns random values. I looked it up and it is a known problem with Numbers. So it's rendered my spreadsheet useless.


I've started testing Excel live, the browser version, then I noticed it can't handle links between sheets. Some cells display the formula rather than cell value, which is also an acknowledge problem by MS (the app, not just the Live version). Their solution is to remake the cell. Thousands of cells by hand? No thank you.


I see why corporations just use custom DB / accounting packages, never spreadsheet apps. Works for small data sets I suppose. Openoffice is another option, but not looking good so far.

Numbers, last 5 games football results

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.