Sports competition top scorer list (round by round)

valmir

Active Member
Joined
Feb 10, 2021
Messages
267
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone!
As the title says, I'm trying to create a top scorer list for a sports competition:
1st round list untouched
2nd round list includes scorers from 1st and 2nd round
3rd round list includes scorers from 1st, 2nd and 3rd round and so forth.
I have three columns as follows:
Column A: round number
Column B: club name
Column C: Player's name
Column D: Goals scored
OBS: Names are unique, which means if same name is found in two teams, he has been transferred, in that case, team column should concatenate both teams
I'm attaching a sample file including first 3 rounds only. Solution should be generic so that I can use it across other files.

Top Scorers.xlsx
ABCD
1RoundClubPlayerGoals
21ATNJames2
31ACAMichael1
41ASARobert1
51BHUJohn1
61BLDDavid1
71PETJoseph1
81PETRichard3
91PETThomas1
101PETWilliam1
111PROChristopher1
121PROCharles1
131SAGDaniel1
141
151
161
171
181
191
201
211
221
231
241
251
262ASARobert1
272BHUAnthony1
282FCCMark1
292PHUDonald1
302PHUSteven1
312PRMAndrew1
322SAGDaniel2
332SAGPaul1
342
352
362
372
382
392
402
412
422
432
442
452
462
472
482
492
503ACAClaude2
513ACAMartin1
523ATNJames1
533BLDDavid1
543FCCJoshua1
553FCCMark1
563KABKevin1
573KABBryan1
583PETRichard2
593PETWilliam1
603PHUDonald2
613PHUGeorge1
623PRIJason1
633PRIMalcom1
643PRMDonald1
653PROBen1
663SAGDaniel
673
683
693
703
713
723
733
Scorers
 
Write in F1:I1 headers: Round Player Club Goals
In F2 write the round after which you want to see the result (even when you know results of x round you can go back to the past and see what was ranking after round x-1).
And in G2 write the formula:
Excel Formula:
=LET(a,FILTER(B:D,(A:A<=F2)*(C:C<>""),SORT(HSTACK(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,1),LAMBDA(b,ARRAYTOTEXT(UNIQUE(b))),,0),CHOOSECOLS(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,3),SUM,,0),2)),3,-1))
Note that for F2=2 Donald was:

DonaldPHU1

and dor F2=3 you will see properly see team change (in round 3 Donald is listed twice for PHU with 2 goals and for PRM with 1

DonaldPHU; PRM4

If you dont want this "history" feature remove headers and use in G1 (as a matter of fact - enywhere in empty cell) a bit shorter formula:
Excel Formula:
=LET(a,FILTER(B:D,C:C<>""),SORT(HSTACK(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,1),LAMBDA(b,ARRAYTOTEXT(UNIQUE(b))),3,0),CHOOSECOLS(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,3),SUM,3,0),2)),3,-1))
[
[/QUOTE]

Write in F1:I1 headers: Round Player Club Goals
In F2 write the round after which you want to see the result (even when you know results of x round you can go back to the past and see what was ranking after round x-1).
And in G2 write the formula:
Excel Formula:
=LET(a,FILTER(B:D,(A:A<=F2)*(C:C<>""),SORT(HSTACK(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,1),LAMBDA(b,ARRAYTOTEXT(UNIQUE(b))),,0),CHOOSECOLS(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,3),SUM,,0),2)),3,-1))
Note that for F2=2 Donald was:

DonaldPHU1

and dor F2=3 you will see properly see team change (in round 3 Donald is listed twice for PHU with 2 goals and for PRM with 1

DonaldPHU; PRM4

If you dont want this "history" feature remove headers and use in G1 (as a matter of fact - enywhere in empty cell) a bit shorter formula:
Excel Formula:
=LET(a,FILTER(B:D,C:C<>""),SORT(HSTACK(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,1),LAMBDA(b,ARRAYTOTEXT(UNIQUE(b))),3,0),CHOOSECOLS(GROUPBY(CHOOSECOLS(a,2),CHOOSECOLS(a,3),SUM,3,0),2)),3,-1))
Hi Kaper! Thanks a lot for your help. Regarding the VBA code, could it be because I have different regional settings that it is not working on my side?
Regarding the formulas you provided, for the first one, I replaced commas by semi-colons, due to regional settings, tried the corrected formula as
Excel Formula:
=LET(a;FILTER(B:D;(A:A<=F2)*(C:C<>"");SORT(HSTACK(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));;0);CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;;0);2));3;-1))
and I got a "the formula is missing an opening or closing parethesis" error message.
Next, I deleted the headers and tried the second formula in G2 and it worked. However, it gave me the intended result for round 3 (round 1+round 2+round 3). What changes do I have to make to the second formula so that I can get the result up until round 2 (round 1 + round 2)? What about round 4? Please explain the logic so that I can change the formula for all the rounds. Besides, can you change the formula so that I get columns in following order: team, name, goals.
This is how I corrected the second formula due to regional settings:
Excel Formula:
=LET(a;FILTER(B:D;C:C<>"");SORT(HSTACK(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));3;0);CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;3;0);2));3;-1))
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
The second formula works for a any number of rounds.
with semicolons (by the way it is also my regional setting) it is:
Excel Formula:
=LET(a;FILTER(B:D;C:C<>"");SORT(HSTACK(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));3;0);CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;3;0);2));3;-1))

the first one with semicolons shall read:
Excel Formula:
=LET(a;FILTER(B:D;(A:A<=F2)*(C:C<>""));SORT(HSTACK(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));;0);CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;;0);2));3;-1))

and it also calculates properly for any number of rounds

As for the columns sequence, I will do that later (going offline at the moment). Probably I'll move Choosecols between first and second argument of HSTACK and in first I'll choose only second (club) column from groupingby, and in second I'll use whole groupby results - name and sum of goals columns):

Excel Formula:
=LET(a;FILTER(B:D;C:C<>"");SORT(HSTACK(CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));3;0);2);GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;3;0));3;-1))

1729506354965.png
 
Last edited:
Upvote 0
Solution
Perfect! Tested and working. The second formula seems easier to me. Now, anyway to change columns order to club, name, goals?
 
Upvote 0
Have you seen my last edit (3rd formula above):
Excel Formula:
=LET(a;FILTER(B:D;C:C<>"");SORT(HSTACK(CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));3;0);2);GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;3;0));3;-1))
 
Upvote 0
Have you seen my last edit (3rd formula above):
Excel Formula:
=LET(a;FILTER(B:D;C:C<>"");SORT(HSTACK(CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;1);LAMBDA(b;ARRAYTOTEXT(UNIQUE(b)));3;0);2);GROUPBY(CHOOSECOLS(a;2);CHOOSECOLS(a;3);SUM;3;0));3;-1))
Sorry Kaper. I'm still a bit slow. Thanks a lot (for the patience too). You saved my day! :)👏👏👏
 
Upvote 0
Hi Kaper! One more thing and please don't be angry :) . The first formula is too complicated for me and the second formula works perfectly. Actually, not only complicated but when I compared the results of both formulas for round 3, formula one had one row short. Anyway, please can you swap the order of columns B and C in formula 2, as you did in formula 1, since formula 2 is the one that is working flawlessly for me? I understand that you swapped the order of columns B and C in the first formula, only! Thanks!
 
Upvote 0
Hi Kaper! One more thing and please don't be angry :) . The first formula is too complicated for me and the second formula works perfectly. Actually, not only complicated but when I compared the results of both formulas for round 3, formula one had one row short. Anyway, please can you swap the order of columns B and C in formula 2, as you did in formula 1, since formula 2 is the one that is working flawlessly for me? I understand that you swapped the order of columns B and C in the first formula, only! Thanks!
I got it!
Excel Formula:
=LET(a; FILTER(B:D; (A:A<=F2)*(C:C<>""));SORT(CHOOSECOLS(HSTACK(GROUPBY(CHOOSECOLS(a;2); CHOOSECOLS(a;1); LAMBDA(b; ARRAYTOTEXT(UNIQUE(b))); ;0);CHOOSECOLS(GROUPBY(CHOOSECOLS(a;2); CHOOSECOLS(a;3); SUM; ;0); 2));2; 1; 3);3; -1))
 
Upvote 0
Glad to hear that, and thanks for marking the solution
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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