Forum Discussion

KStecyk's avatar
KStecyk
Brass Contributor
Sep 29, 2020

How to Reference the Last Cell in a Column in a Table?

Sheet One with TableSheet Two Referencing Prior Table

 

I have a table where I add data at the end of every day. I would like a formula to reference the last value in a column. Is there an easy way to do that? In the photos above, I would like B5 on Sheet2 to reference the value in E14 on Sheet1, which is the last value in KeyThree column.

 

I am not well versed in commands for tables. 

 

Aside from specific table commands, by knowing the count, I could use index or offset to reference the appropriate cell. But I am curious if there is a more elegant solution where I don't have to keep track of the count.

 

I have uploaded this simple spreadsheet.

 

I look forward to your comments. Thank you.

  • KStecyk's avatar
    KStecyk
    Sep 29, 2020
    Thank you for your reply. I looked at your and JMB17's reply to create me own.

    Initially, I mentioned about the count. I did not want to have to manually keep track of the count, but I can use the count function to help me.

    I am not sure how to show code, but my formula is as follows:

    ` =INDEX(KeyTable[KeyThree], COUNT(KeyTable[KeyThree]))

    It's really just a hybrid of the two prior ideas.

    Thank you for helping me with this small problem.
    • KStecyk's avatar
      KStecyk
      Brass Contributor
      Thank you for your reply. I looked at your and JMB17's reply to create me own.

      Initially, I mentioned about the count. I did not want to have to manually keep track of the count, but I can use the count function to help me.

      I am not sure how to show code, but my formula is as follows:

      ` =INDEX(KeyTable[KeyThree], COUNT(KeyTable[KeyThree]))

      It's really just a hybrid of the two prior ideas.

      Thank you for helping me with this small problem.
      • RobBaston's avatar
        RobBaston
        Copper Contributor

        KStecyk 

        Or you can use the offset function for  a column of numbers as in:

         

        OFFSET(Bank[[#Headers],[Book Balance]],COUNT(Bank[Book Balance]),0)

         

        Here, Bank is a table & Book Balance is a column name therein so the offset cell is the header to the column Book Balance and so the offset formula points to the last entry in that column. 

    • KStecyk's avatar
      KStecyk
      Brass Contributor
      Thank you, JMB17, for your reply. It helped me to create my own formula, which I will show in the next reply.
  • KStecyk 

    Like the INDEX/MATCH this will return a single-cell range reference

    = LET(
      field, KeyTable[KeyThree],
      XLOOKUP(1, SIGN(field), field,,,-1) )

    The LOOKUP formula would do fine to return the value.

    • KStecyk's avatar
      KStecyk
      Brass Contributor

      PeterBartholomew1 

       

      Thank you, Peter, for your response. While I am confident that your solution works mighty fine, it looks complicated to me. I am okay with the Let function, but the XLOOKUP with all the different arguments seems complicated. Even so, it is good to see different alternatives. Sometimes, though, it is good to do things differently. So I appreciate your help.

    • KStecyk's avatar
      KStecyk
      Brass Contributor

      PeterBartholomew1 

      I very much appreciate the time you've taken to create a novelty spreadsheet. I am learning from you.

       

      I found your formulas break if the last value is negative. That is, the formula gives the wrong answer. I tried to create a formula to address this weakness, but my formula doesn't work. I am hoping you can spot my error and fix.

       

       

      I have included a version 2 of your spreadsheet. 

       

      I look forward to your response. 

       

      Kevin

  • I'm using Power Query on Excel for Mac. I save my "iqy" file to a Queries Folder, but then when I go to to Excel and go to Data/Get External Data/Run Web Query, my "iqy" files are all greyed out, except for the sample files from MS which are not greyed out. Does anyone know why my files would be greyed out and how to change that.
    • KStecyk's avatar
      KStecyk
      Brass Contributor

      Deleted

      Rather than hijacking this thread with your different topic, you'll likely get more success with your own separate thread. That way, people can see and focus on your specific question. If they read my question, they might not even bother to read further.

      Good luck.

Resources