+ Reply to Thread
Results 1 to 9 of 9

Alternative to OFFSET for finding second-to-last entry?

  1. #1
    Registered User
    Join Date
    11-09-2021
    Location
    Sheffield
    MS-Off Ver
    Office 365
    Posts
    15

    Question Alternative to OFFSET for finding second-to-last entry?

    I am a relatively new user of the more advanced Excel formulas, and have often relied on finding solutions online and managing to adapt them to my needs. I'm really struggling with something though, which I thought OFFSET had helped (I copied the formula from a page I found online) but it's too volatile for the amount of data I have in my worksheets. So if anyone can help me, I'd be really grateful. I am going to do an Excel course, but in the meantime...

    Let's say I have survey responses that people have given to a particular question. They can choose one of three different answers, and I have used Define Name to give each of those answers a value. I'm also collecting their responses over time - so in column F I have their response on Day 1, in G I have six months, and in H I have 12 months and so on. So if each row is a person, I have maybe five columns available for their response to this same question over time. For some people I might have four responses, for others I might only have two, because not everyone joined my survey at the same time.

    eg.PNG

    So if I want to calculate the difference between their most recent response and the one before that, I'd ultimately like a formula that will judge if the value of their most recent responses is higher or lower than the value of their previous answer. But to get there, I need a formula that will find the second-to-last entry.

    =OFFSET(F5:J5,0,COUNTA(F5:J5)-2,1,1)

    As I said, I was using OFFSET, but it is too volatile. I have read about using INDEX with a colon, but I don't understand the syntax well enough to adapt it to my needs.

    I'm very sorry if this is a stupid question. I really appreciate any help.
    Attached Files Attached Files
    Last edited by georgie_t; 11-10-2021 at 06:09 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Alternative to OFFSET for finding second-to-last entry?

    See yellow banner on how to post a workbook.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Alternative to OFFSET for finding second-to-last entry?

    I think that you are over thinking this.

    =COUNTA(F1:J1) will return the number of cells in your row so if no entries =if (COUNTA(F1:J1)=0 , "")

    Try this formula =IF(COUNTA(F5:J5)=0,"Empty Row", IF(COUNTA(F5:J5)=1,"Only Entry: "&F5,OFFSET(E5,0,COUNTA(F5:J5)-1) &" Now "&OFFSET(E5,0,COUNTA(F5:J5))))
    Attached Files Attached Files
    Last edited by mehmetcik; 11-09-2021 at 02:20 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    11-09-2021
    Location
    Sheffield
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Alternative to OFFSET for finding second-to-last entry?

    Apologies, I've now added a workbook. As you can see, I can get LOOKUP and OFFSET to work, but I'm struggling to combine them to calculate the difference. And I don't want to use a formula containing OFFSET at all if I can avoid doing so, as I have a lot of data in the workbook. I really appreciate advice - and please feel free to explain things as you would to an idiot. That is essentially what I am here. Thanks again.

  5. #5
    Registered User
    Join Date
    11-09-2021
    Location
    Sheffield
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Alternative to OFFSET for finding second-to-last entry?

    Thank you very much - I'm not sure I entirely understand how it works, but looking at the file I can see that it does work! Is there no avoiding using OFFSET, do you think? Thanks so much for your advice.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Alternative to OFFSET for finding second-to-last entry?

    Most recent

    =INDEX($C3:$F3,,COUNTA($C3:$F3))

    Previous

    =INDEX($C3:$F3,,COUNTA($C3:$F3)-1)

    Then reference columns J/K for difference calculation

    I would "rank" the responses by assigning a numeric value to each and doing a simple compare.

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Alternative to OFFSET for finding second-to-last entry?

    Frankly i would stick with Offset. it is designed for the job.

    If no data then return "Empty Row" in the real world return ""
    =IF(COUNTA(F5:J5)=0,"Empty Row",

    If One Entry then Return F5
    IF(COUNTA(F5:J5)=1,"Only Entry: "&F5,

    If more then one entry then COUNTA(F5:J5) tells you the number of entries
    OFFSET(E5,0,COUNTA(F5:J5)) Returns your last entry
    OFFSET(E5,0,COUNTA(F5:J5)-1) Returns the first from last entry

    OFFSET(E5,0,COUNTA(F5:J5)-1) &" Now "&OFFSET(E5,0,COUNTA(F5:J5))))


    Building on Johns suggestion. But using the Let function as well

    =LET(Entry,F5:J5,IF(COUNTA(F5:J5)=0,"Empty Row",IF(COUNTA(F5:J5)=1,"Only Entry: "&F5,INDEX(Entry,1,COUNTA(Entry))&" Now "&INDEX(Entry,1,COUNTA(Entry)))))

    Define Entry as the range F5 to J5
    =LET(Entry,F5:J5

    If no data then return "Empty Row" in the real world return ""
    ,IF(COUNTA(F5:J5)=0,"Empty Row",

    If One Entry then Return F5
    IF(COUNTA(F5:J5)=1,"Only Entry: "&F5,

    If more then one entry then COUNTA(F5:J5) tells you the number of entries
    Index(Entry,1,COUNTA(F5:J5)) Returns your last entry
    Index(Entry,1,COUNTA(F5:J5)-1) Returns the first from last entry
    INDEX(Entry,1,COUNTA(Entry))&" Now "&INDEX(Entry,1,COUNTA(Entry)))))
    Last edited by mehmetcik; 11-09-2021 at 03:32 PM.

  8. #8
    Registered User
    Join Date
    11-09-2021
    Location
    Sheffield
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Alternative to OFFSET for finding second-to-last entry?

    Thank you very much, I really appreciate your help on this.

  9. #9
    Registered User
    Join Date
    11-09-2021
    Location
    Sheffield
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Alternative to OFFSET for finding second-to-last entry?

    Thank you so much for explaining things for me, I can't tell you how much I appreciate it.

+ 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. [SOLVED] INDEX alternative to OFFSET
    By RaulSerg in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-10-2021, 07:51 AM
  2. [SOLVED] Alternative to Offset
    By SimonCampbell in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-09-2017, 10:08 AM
  3. Alternative to INDIRECT (and OFFSET)
    By frewag in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-11-2016, 08:38 AM
  4. [SOLVED] Activecell.offset alternative
    By Boltsie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-06-2016, 04:44 PM
  5. Help with OFFSET, or an alternative
    By froment in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2015, 03:25 PM
  6. [SOLVED] SpeedUp/Alternative to Offset.Value = Offset.Value
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 01:43 AM
  7. Alternative to Offset in a formula
    By ashokunbi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-22-2013, 08:33 PM

Tags for this Thread

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