Find 5 most recent bits of data via a Date - Most Recent first

James8761

Board Regular
Joined
Apr 24, 2012
Messages
154
Office Version
  1. 2019
Platform
  1. Windows
Hi All,


Another project I am working on. I have a database of football results. I am trying to create a visual via a formula rather than linking manually.

I am trying to get a football teams most recent last 5 results. The 5 most recent Home results for the team playing at home today and the 5 most recent Away results for the team playing Away today.

I’ve set a dummy game up, Liverpool v Leeds.

On Sheet 2 I have manually linked the end result I would like to do. Is there a way I can do this via a formula though?

My football database is in the tab titled ALL.

This is the end result I would like to see.

1597917922615.png



This is the copy of Leeds Away data. the columns I am interested in picking data up from is Column B, the date. (I have this ordered oldest to newest). Column E the Away team name and Column H, the Full time Result.

1597917806887.png


Similarly, for Liverpool the columns I am interested in picking data up from is Column B, the date. (I have this ordered oldest to newest). Column D the Home team name and Column H, the Full time Result.

1597917893391.png


Is there a way I can put formulas in Cells C5:L5 of Sheet 2 to capture the data I want please?

Any help greatly appreciated.

Kind regards,
James
 

Attachments

  • 1597917688012.png
    1597917688012.png
    49.6 KB · Views: 7

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
How about
+Fluff New.xlsm
ABCDEFGHIJKL
1
2
3
4HomeAwayLast 5 Games Home TeamLast 5 Games Away Team
5LiverpoolLeeds2-13-14-02-02-00-40-11-12-01-0
6
Sheet2
Cell Formulas
RangeFormula
C5:G5C5=INDEX(SORT(FILTER(All!B2:H9000,All!D2:D9000=A5),1,-1),SEQUENCE(,5),7)
H5:L5H5=INDEX(SORT(FILTER(All!B2:H9000,All!E2:E9000=B5),1,-1),SEQUENCE(,5),7)
Dynamic array formulas.

Hi Fluff,

I hope you are well. When I e-mailed yesterday I was on the work laptop, now I am using my personal one. (I'll be using the personal one for this project).

I have this version of Excel at home.......would you know a formula that would work in the below version please? Kind regards, James

1597992005713.png
 
Upvote 0
Have you tried the formula from CA_Punit?
 
Upvote 0
Did you confirm it with Ctrl Shift Enter, rather than just Enter? If so you should see the formula wrapped in {}
 
Upvote 0
Did you confirm it with Ctrl Shift Enter, rather than just Enter? If so you should see the formula wrapped in {}
HI, yes, I have those around it. I have moved the data around and now I am placing the formula in Cell AW5 of Tab called Sheet2, the data is on the tab titled ALL. I've copied it down a few rows, but ti just gives me the most recent result 5 times.

Database 200821.xlsx
I
219462
ALL


Database 200821.xlsx
BA
52-1
Sheet2
Cell Formulas
RangeFormula
BA5BA5=INDEX(ALL!$W$2:$W$350000,MATCH(AGGREGATE(14,6,IF($A5=ALL!$D$2:$D$350000,ALL!$B$2:$B$350000),{1,2,3,4,5}),IF($A5=ALL!$D$2:$D$350000,ALL!$B$2:$B$350000),0))
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AX5:BA11Expression=$BJ5="L"textNO
AX5:BA11Expression=$BJ5="D"textNO
AX5:BA11Expression=$BJ5="W"textNO
 
Upvote 0
Ok, with your original layout, how about
+Fluff New.xlsm
ABCDEFGHIJKLM
1
2
3
4HomeAwayLast 5 Games Home TeamLast 5 Games Away Team
5LiverpoolLeeds2-13-14-02-02-00-40-11-12-01-0
6
7
Sheet2
Cell Formulas
RangeFormula
C5:G5C5=INDEX(All!$H$2:$H$35,AGGREGATE(14,6,(ROW(All!$H$2:$H$35)-ROW(All!$H$2)+1)/(All!$D$2:$D$35=$A5),COLUMNS($C5:C5)))
H5:L5H5=INDEX(All!$H$2:$H$35,AGGREGATE(14,6,(ROW(All!$H$2:$H$35)-ROW(All!$H$2)+1)/(All!$E$2:$E$35=$B5),COLUMNS($H5:H5)))
 
Upvote 0
Ok, with your original layout, how about
+Fluff New.xlsm
ABCDEFGHIJKLM
1
2
3
4HomeAwayLast 5 Games Home TeamLast 5 Games Away Team
5LiverpoolLeeds2-13-14-02-02-00-40-11-12-01-0
6
7
Sheet2
Cell Formulas
RangeFormula
C5:G5C5=INDEX(All!$H$2:$H$35,AGGREGATE(14,6,(ROW(All!$H$2:$H$35)-ROW(All!$H$2)+1)/(All!$D$2:$D$35=$A5),COLUMNS($C5:C5)))
H5:L5H5=INDEX(All!$H$2:$H$35,AGGREGATE(14,6,(ROW(All!$H$2:$H$35)-ROW(All!$H$2)+1)/(All!$E$2:$E$35=$B5),COLUMNS($H5:H5)))

That's excellent, does exactly what I want it to. Thank you very much and thank you for your patience!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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