+ Reply to Thread
Results 1 to 16 of 16

Find last value, second last value, third last value etc.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Find last value, second last value, third last value etc.

    Hi everyone

    Consider my example Excel sheet. Column B contains the match results in the form of either W (Win), D (Draw) or L (Loss), or "" if not any of those three. My actual formulas in column B work just fine ? I'm just using <Formula> here since this is just a small sample from my actual workbook.

    Is there a way - using formulas - to get Excel to fetch the last three results for Arsenal? The last result should be put in cell H1, second last in G1, third last in F1. In my example sheet I have manually put in those values (W, L, D). But how can I make a formula that does this automatically?


    EDIT: Full Excel uploaded (Ligatabell.xlsm)
    Attached Files Attached Files
    Last edited by Whitestar127; 05-25-2023 at 07:21 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    Welcome to the forum.

    A good sample workbook has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    The 'updated' workbook is the same as before - there are still no expected results mocked up.

    EDIT: I see now what you want. Do you not have MS365?

    It would be MUCH easier if you did not replace formula results with <formula> - keep the formula results instead.
    Last edited by AliGW; 05-25-2023 at 05:35 AM.

  4. #4
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Re: Find last value, second last value, third last value etc.

    Ok, so I should upload the full Excel file? I thought you wanted small sample files as examples.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    You can oversimplify your examples, and that's what you have done here.

    Please confirm that your version is 2016 and not 365 - this would be super easy with the latter!

  6. #6
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Re: Find last value, second last value, third last value etc.

    Actually I have 365 at work and 2016 at home
    I would want something that would work in both versions, but of course I welcome the solution for 365 if you only have that.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,328

    Re: Find last value, second last value, third last value etc.

    How are the expected answers the 3rd last... then there is only 2 W and 1 L & D????
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    You still haven't provided a decent sample workbook. I asked you to get rid of <formula> and replace it with the value in those cells. You also need to supply data for more than one team. Your sample is OVER-SIMPLIFIED.

    Here's a 365 solution for two teams:

    =LET(f,FILTER($B$2:$C$38,($B$1:$C$1=E1)),ff,FILTER(f,f<>""),TRANSPOSE(TAKE(ff,-3)))

    See the workbook - I have assumed that the formula returns blanks where there is no data. If it doesn't then you need to show what it does return. As I say, an over-simplified sample workbook is not really a lot of use.
    Attached Files Attached Files

  9. #9
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Find last value, second last value, third last value etc.

    Please try in F1 and copy down:
    Formula: copy to clipboard
    =LET(t,B$2:C$38,c,INDEX(t,,MATCH(E1,B$1:C$1,0)),IFNA(TRANSPOSE(TAKE(FILTER(c,c>""),-3)),""))
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Re: Find last value, second last value, third last value etc.

    Thanks, I have uploaded the full Excel.

    Apologies for not explaining properly. What i'm interested in is a formula that can extract the last 3 results for all the teams, to see their current form. So for Arsenal in this case (in the complete Excel-file) it's draw, loss and win (BA38, BA27, BA13). And I'd want those results in cells GN2, GM2 and GL2 respectively.
    Last edited by Whitestar127; 05-25-2023 at 06:46 AM.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    There you go - a completely different set-up to what you provided in the original sample!

    Back to square one - I'll have another look later (no time now - sorry).

  12. #12
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Re: Find last value, second last value, third last value etc.

    Quote Originally Posted by AliGW View Post
    There you go - a completely different set-up to what you provided in the original sample!

    Back to square one - I'll have another look later (no time now - sorry).
    Not quite back to square one, because your formula works perfectly in my complete workbook, so thanks! I inserted this into cell GL2:
    =LET(f;FILTER($BA$2:$BA$381;($BA$1:$BA$1=BA1));ff;FILTER(f;f<>"");TRANSPOSE(TAKE(ff;-3)))
    The only thing now is to figure out how to do this in Excel 2016. Will it involve several steps maybe? Is it possible at all?
    Last edited by Whitestar127; 05-25-2023 at 07:17 AM.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,836

    Re: Find last value, second last value, third last value etc.

    It will involve more steps - someone else will be able to help you.

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Find last value, second last value, third last value etc.

    The formulas that AliGW and I posted in post #8 and #9 also work in the complete workbook.

    You just need to change the references.

    Please try in GL2 and copy down:
    Formula: copy to clipboard
    =LET(t,BA$2:GD$381,c,INDEX(t,,MATCH(GK2,BA$1:GD$1,0)),IFERROR(TRANSPOSE(TAKE(FILTER(c,c>"")), -3)),""))
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    05-16-2023
    Location
    Norway
    MS-Off Ver
    Home and Student 2016
    Posts
    6

    Re: Find last value, second last value, third last value etc.

    Quote Originally Posted by HansDouwe View Post
    The formulas that AliGW and I posted in post #8 and #9 also work in the complete workbook.

    You just need to change the references.

    Please try in GL2 and copy down:
    Formula: copy to clipboard
    =LET(t,BA$2:GD$381,c,INDEX(t,,MATCH(GK2,BA$1:GD$1,0)),IFERROR(TRANSPOSE(TAKE(FILTER(c,c>"")), -3)),""))
    Thanks, I did that and it worked fine in Excel 365.
    But I also need it to work in Excel 2016, and that's a bit more complicated apparently.

  16. #16
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Find last value, second last value, third last value etc.

    Yes its more complicated, because Excel 2016 does not have the functions LET, FIILTER and TAKE

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 06-25-2022, 03:04 PM
  2. [SOLVED] FIND function to find this value or if that isn't existing, find this value
    By neilosj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2021, 07:46 AM
  3. Replies: 3
    Last Post: 01-15-2019, 03:58 AM
  4. Replies: 3
    Last Post: 08-18-2015, 09:04 AM
  5. Replies: 9
    Last Post: 12-21-2014, 06:29 PM
  6. Replies: 4
    Last Post: 09-18-2012, 10:54 AM
  7. Replies: 1
    Last Post: 01-31-2006, 06:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1