reversing rows in excel formulas - excel

(A) SumProduct( A1:A3,B1:B3) == A1*B1 + A2*B2 + A3*B3
Instead, what I'm after is
(B) SumProduct( A1:A3, Reverse(B1:B3)) == A1*B3 + A2*B2 + A3*B1
Is there a clean way to achieve this in excel 2003 / excel 2007 ? The natural ordering of these values is A1->A3 and B1->B3, so reversing the meanings of the cells is unsatisfactory; but creating a reversed copy of B1:B3 elsewhere in the worksheet seems clumsy.

Check the topic "Transposing A List Of Data" in http://www.cpearson.com/EXCEL/lists.htm

I chanced upon this question because I was trying to find an answer to this very question, in particular a solution to be used with SUMPRODUCT.
Previous post with link was useful, and the following has been devised. Please, note that for simplicity and clarity original references have been changed to make spreadsheet formulas easier to understand. Necessary changes can be achieved by using INDIRECT and R1C1 reference style if reversal needs to be applied to columns (INDIRECT, COLUMN and COLUMNS function documentation would prove useful).
In Excel (checked in Excel 2010), the formula that SUMPRODUCTs an array in A6:A8 with the reversal of the array in B6:B8 (let's say B8:B6) could be
=SUMPRODUCT(A6:A8,N(OFFSET(B6:B8,ROWS(B6:B8)-ROW(INDIRECT("A1:A"& ROWS(B6:B8))),0)))
The reversing part for Excel is N(OFFSET(B6:B8,ROWS(B6:B8)-ROW(INDIRECT("A1:A"& ROWS(B6:B8))),0)), it can also be used as a multi-cell array formula (ctrl-shift-enter) anywhere - the array to be reversed is in B6:B8.
Brief explanation: N() is necessary to convert the references returned by OFFSET into an array of values that can be used inside SUMPRODUCT. (OFFSET without N() render the formula inoperative within SUMPRODUCT, and it converts most non numbers into 0, as expected it converts TRUE to 1.)
OFFSET takes the array on the spreadsheet and puts the values in reverse order. (In this case, offset original at 3-1=2 goes new array position 0, 3-2=1 goes to 1, and finally 3-3=0 goes to 2.) ROW() function creates an array of consecutive numbers that can be subtracted from the length of the total array [please note, no final S, and A1:A3 has been used to obtain {1,2,...}, up to the number of rows in the original array/range.]
This formula does NOT work in OpenOffice/LibreOffice spreadsheet application. But INDEX can with an analogue approach becoming even more flexible.
OpenOffice/LibreOffice can use the same approach but with the INDEX function. OpenOffice/LibreOffice solution does not work in Excel as Excel does not accept arrays in INDEX's row_num/col_num (any array as argument there becomes the single top element of the array).
In OpenOffice/LibreOffice (checked in Apache OpenOffice 4), the formula that SUMPRODUCTs an array in A6:A8 with the reversal of the array in B6:B8 could be
=SUMPRODUCT(A6:A8,INDEX(B6:B8,1+ROWS(B6:B8)-ROW(INDIRECT("A1:A"& ROWS(B6:B8))),0))
The reversing part for OpenOffice is INDEX(B6:B8,1+ROWS(B6:B8)-ROW(INDIRECT("A1:A"& ROWS(B6:B8))),0), it can also be used as a multi-cell array formula (ctrl-shift-enter) anywhere - the array to be reversed is in B6:B8.
Excel version with this approach (thanks, XOR LX: see here) which might be very useful as INDEX can take arrays whereas OFFSET can only take references to a worksheet:
=SUMPRODUCT(A6:A8,INDEX(B6:B8,N(INDEX(1+ROWS(B6:B8)-ROW(INDIRECT("A1:A"& ROWS(B6:B8))),,)),0))
[As it happens with Excel's OFFSET version above, the formula with the N(INDEX([...],,)) modification does not work in OpenOffice, the wrapping function must be taken out if using that application.]
The approach is analogue to the one used in Excel for OFFSET. Take into account that INDEX uses indexes starting with 1 whereas OFFSET starts with 0. As it happens with the previous case, an array is dynamically created from the row numbers in A1:A3 to be used as both template for the array and position change index.
This very late answer is unlikely to help the original poster, but it might save time to future users with a similar question.

I cannot see a solution that doesn't involve (a) custom functions in VBA (or similar) or (b) an extra column with partial results.
If you don't like column C becoming a (hidden) reverse list, would you accept column C becoming a list like: A1*B3, A2*B2, A3*B1, which could then be summed? It would be possible to use a similar formula to the one mentioned in #e.tadeu's answer to obtain this (using OFFET and ROW functions.)

Related

Multiply based on condition then sum results ( multiply if empty <> ) in google sheets

I need help in writing a formula in cell b7. The formula must look to the right and multiply the nonempty cells by the corresponding value in row 3, and I would like to sum up the results.
File link provided.
FILE LINK
ScreenShot
Please see my comment to your original post.
That said, I will try to explain how to approach this as I think you intend. (This solution will be a Google Sheets solution which will not work in Excel.)
The first thing you will need to do is to delete everything from Row 11 down: all of your examples and notes must be deleted for the following proposed formula to work correctly.
Once you have no superfluous data below your main chart, delete everything from B6:B (including the header "Total").
Then, place the following formula in cell B6:
={"TOTAL"; FILTER(MMULT(C7:G*1, TRANSPOSE(C$3:G$3*1)), A7:A<>"")}
This formula will return the header text "TOTAL" (which you can change within the formula itself if you like) followed by the calculation you want for each row where a name is listed in A7:A.
MMULT is a difficult function to explain, but it multiplies one matrix ("grid") or numbers by another matrix ("grid") and returns the sum of all products per row (or per column, depending on how you set it up) —— which is what you are trying to do.
MMULT must have every element of both matrices be a real number. To convert potential nulls to zeroes, you'll see *1 appended to each range (since null times 1 is zero).
This assumes that all data entered into C7:G and C3:G3 will always be either a number or null. If you enter text, you'll throw the formula into an error. If you think accidental text entries in those ranges are possible, use this version instead:
={"TOTAL"; FILTER(MMULT(IFERROR(C7:G*1, ROW(C7:G)*0), TRANSPOSE(IFERROR(C$3:G$3*1, COLUMN(C$3:G$3)*0))), A7:A<>"")}
The extra bits use IFERROR to exchange error-producing entries with zeroes, since MMULT must have every space in both matrices filled with a real number.

Excel: Lookup multiple values in one cell and return results in another

I'm trying to find a way to lookup each of several comma separated values in one cell, and return the results as a comma separated list in another cell.
The number of values to lookup is not constant, it may be only one, or several hundred.
Example - Sheet A has the initial values and will hold the returned values. Sheet B is the table with the data to lookup.
EDIT: I've gotten better and learned how to make this a 1-liner. I'll leave my original answer below, but here's my updated one (as this hasn't been accepted or even commented on, yet):
=TEXTJOIN(", ",TRUE,INDEX(SheetB!$A$2:$B$6,MATCH(FILTERXML("<x><y>"&SUBSTITUTE($B2,",","</y><y>")&"</y></x>","//y"),SheetB!$A$2:$A$6,0),2),"")
I think INDEX/MATCH was the key component I hadn't learned yet when I tried answering this before. :)
The FILTERXML/SUBSTITUTE I had learned from another site where it takes in your delimited values and replaces the delimiter and wraps the rest with the needed xml tags for FILTERXML to then return an array of your values.
INDEX/MATCH then does your lookup, first getting the row number via MATCH (note the final value of 0 in MATCH means exact match), then INDEX returns the value of the corresponding matching column (the 2 at the end of INDEX's arguments).
Finally, TEXTJOIN joins the results together with the delimiter of your choice (and the second argument set to TRUE allows it to skip blanks).
As a final note, I think this solution may work without Office 365. FILTERXML appears to have been available as early as Office 2013.
Original, outdated answer follows:
I've been searching for an answer to this myself and was rather dismayed to find your question - exactly the question I have - without an answer.
Almost 4 years late, this answer does require Office 365 Excel, and it's not the most elegant, but here's what I've been able to come up with.
Pick an unused column on your Sheet B (with enough contiguous unused columns to its right to handle spillover of however many values you'll need to be splitting, or use a new sheet dedicated to this) and put this formula into the 2nd row's cell for that column, dragging it down through each cell that has corresponding data back on Sheet A (and assuming your column header "File #s" is column B): =TRANSPOSE(FILTERXML("<x><y>"&SUBSTITUTE(SheetA!$B2,delim,"</y><y>")&"</y></x>","//y"))
Replace delim with your delimiter wrapped in quotes, or a cell reference to a cell that has your delimiter in it. Also, if it's possible to have no value in the corresponding cell in Sheet A, then you'll need to wrap the FILTERXML() function (or the whole thing) with IFERROR().
Then, back on Sheet A in your Results column, use this formula: =TEXTJOIN(delim,TRUE,FILTER(SheetB!$B$2:$B$6,COUNTIF(SheetB!D2#,SheetB!$A$2:$A$6),if_no_match))
Again, replace delim with the delimiter or cell reference with your delimiter of choice. SheetB!$B$2:$B$6 and SheetB!$A$2:$A$6 are your lookup table's columns (and thus extend them to encompass the whole thing). The SheetB!D2# references the column where you put the TRANSPOSE(FILTERXML()) formula. Finally, replace if_no_match with whatever you want to appear if there was no match.
I'd ideally like to find a way that uses a single, self-contained formula, but alas, this is as far as I've managed so far.

Why this array formula doesn't work?

On the illustration all formulas are array. The range that each formula spans is bordered, and the first formula on each block is written on the top of that block.
Range A4:A103 is an input vector (which is numeric), range C4:G23 is a given (input) permutation of the rows of A4:A103 (necessarily positive non-zero integer numbers not greater then the length of the input vector).
Let us I interpret the permutation matrix as set of rows.
How to compute for each row in a constant number of cells the minimal number in the input vector? By the constant number of cells, I mean solution, that would require fixed number of cells for each row, regardless of the number of columns in permutation. (In the production case each dimension is much, much bigger; there is about 100 columns in the permutation matrix.)
I don't ask for VBA solutions. If it is necessary the solution can use a free and publicly available Excel add-on, like MoreFunc, but I'd prefer to keep it vanilla Excel 2007 or later.
I thought that the formula {=MIN(INDEX(INDIRECT($A$2);$C4:$G4))} would solve my problem. Surprisingly, Excel seems to not take into account the array nature of the formula, and evaluates it as if it was written as =MIN(INDEX(INDIRECT($A$2);$C4) which is equivalent to dysfunctional =INDEX(INDIRECT($A$2);$C4).
On the other hand, we can see the argument to the MIN is understood as array in the range I4:M4.
INDEX works in some strange ways!
Normally INDEX can't return an array - although you seem to have found the one exception to that - when it's an array formula entered in a range.
You should be able to use OFFSET to return the required array that will work within MIN, i.e. with this formula
=MIN(N(OFFSET(INDIRECT($A$2);$C4:$G4-1;0)))
confirmed with CTRL+SHIFT+ENTER

Is there a function, that would return "" when input ref is empty, and its contents if it is not?

IMO Excel has weird treatment of empty Cells.
I am building a complex array formula. One of the referenced ranges contain cells, that may, or may not be empty, and if not empty, they can contain both numeric values and strings.
What function can I use, to get the value of the cell if the cell is not empty, and "" (or anything other non-numeric, e.g. #N/A) if the cell is empty?
I want to get something like this working:
=MIN(OFFSET(<column vector that contains text, numbers and empty cells>;<row vector of indices>-1;0))
This form of formula returns an #ARG error, as was explained in the answer to Why this array formula doesn't work?.
But when I prefix the OFFSET with N, it transforms any empty cell into 0, so the net result is 0 (unless there are negative numbers in the column vector).
=MIN(L(OFFSET(<column vector>;<row vector of indices>-1;0)))
Is there any formula, that only dereferences the reference returned by OFFSET preserving the "emptyness" of the empty cell? Or maybe there is an alternate way of solving the problem, like
=MIN(IF(OFFSET(<column vector>;<row vector of indices>-1;0)="",L(OFFSET(<column vector>;<row vector of indices>-1;0)),""))
(This example also fails with #ARG, because, as I understand, I need to dereference the array reference for the = test as well).
If it is at all possible, I prefer to keep with Excel 2007 set of built-in functions. And no VBA.
I would accept any solution, that uses constant number of cells irregardless of the size of each input array.
EDIT:
As a side remark I wonder what is wrong with the arrays returned by OFFSET anyway? This simple example works perfectly:
...while the array returned by OFFSET somehow wants to be alone in the formula.
There may be another option but I don't see it at the moment.....
You can filter out zeroes by using an IF like this
=MIN(IF(N(OFFSET(INDIRECT($A$2),$C4:$G4-1,0))<>0,N(OFFSET(INDIRECT($A$2),$C4:$G4-1,0))))
but that won't distinguish between any actual zeroes in your range and those produced when the N function encounters blanks or text
Edit
This version should work
=MIN(IF(COUNTBLANK(OFFSET(INDIRECT($A$2),$C4:$G4-1,0,1))+LEN(T(OFFSET(INDIRECT($A$2),$C4:$G4-1,0,1))),"",N(OFFSET(INDIRECT($A$2),$C4:$G4-1,0,1))))
Perhaps not completely relevant here but the problem is finding functions that can deal with the "array of references" returned by OFFSET with this type of setup - N and T work as shown here and also COUNTBLANK. Other functions that can be used on the OFFSET output are SUBTOTAL and COUNTIF. Note that COUNTBLANK (along with SUBTOTAL and COUNTIF) can work on ranges while T and N will only work with single values - if the latter functions are applied to ranges they simply look at the first value in the range - because of that I was able to use OFFSET without the "height" parameter but you need that with COUNTBLANK (and it's a good habit to get in to so OFFSET should have the final 1 as here
=OFFSET(INDIRECT($A$2),$C4:$G4-1,0,1)
Consider in B1:
=IF(ISBLANK(A1),"nothing there",A1)
So if A1 contains the formula:
=""
Then B1 will also display the null.
Another possibility:
=MIN(CELL("contents",OFFSET(INDIRECT($A$2),N(INDEX($C4:$G4-1,)),0)))
Note: The N(INDEX(...)) part is a trick used to enforce array evaluation.

Last non-empty cell in a column

Does anyone know the formula to find the value of the last non-empty cell in a column, in Microsoft Excel?
Using following simple formula is much faster
=LOOKUP(2,1/(A:A<>""),A:A)
For Excel 2003:
=LOOKUP(2,1/(A1:A65535<>""),A1:A65535)
It gives you following advantages:
it's not array formula
it's not volatile formula
Explanation:
(A:A<>"") returns array {TRUE,TRUE,..,FALSE,..}
1/(A:A<>"") modifies this array to {1,1,..,#DIV/0!,..}.
Since LOOKUP expects sorted array in ascending order, and taking into account that if the LOOKUP function can not find an exact match, it chooses the largest value in the lookup_range (in our case {1,1,..,#DIV/0!,..}) that is less than or equal to the value (in our case 2), formula finds last 1 in array and returns corresponding value from result_range (third parameter - A:A).
Also little note - above formula doesn't take into account cells with errors (you can see it only if last non empty cell has error). If you want to take them into account, use:
=LOOKUP(2,1/(NOT(ISBLANK(A:A))),A:A)
image below shows the difference:
This works with both text and numbers and doesn't care if there are blank cells, i.e., it will return the last non-blank cell.
It needs to be array-entered, meaning that you press Ctrl-Shift-Enter after you type or paste it in. The below is for column A:
=INDEX(A:A,MAX((A:A<>"")*(ROW(A:A))))
Here is another option: =OFFSET($A$1;COUNTA(A:A)-1;0)
I know this question is old, but I'm not satisfied with the answers provided.
LOOKUP, VLOOKUP and HLOOKUP has performance issues and should really never be used.
Array functions has a lot of overhead and can also have performance issues, so it should only be used as a last resort.
COUNT and COUNTA run into problems if the data is not contiguously non-blank, i.e. you have blank spaces and then data again in the range in question
INDIRECT is volatile so it should only be used as a last resort
OFFSET is volatile so it should only be used as a last resort
any references to the last row or column possible (the 65536th row in Excel 2003, for instance) is not robust and results in extra overhead
This is what I use
when the data type is mixed: =max(MATCH(1E+306,[RANGE],1),MATCH("*",[RANGE],-1))
when it's known that the data contains only numbers: =MATCH(1E+306,[RANGE],1)
when it's known that the data contains only text: =MATCH("*",[RANGE],-1)
MATCH has the lowest overhead and is non-volatile, so if you're working with lots of data this is the best to use.
Inspired by the great lead given by Doug Glancy's answer, I came up with a way to do the same thing without the need of an array-formula. Do not ask me why, but I am keen to avoid the use of array formulae if at all possible (not for any particular reason, it's just my style).
Here it is:
=SUMPRODUCT(MAX(($A:$A<>"")*(ROW(A:A))))
For finding the last non-empty row using Column A as the reference column
=SUMPRODUCT(MAX(($1:$1<>"")*(COLUMN(1:1))))
For finding the last non-empty column using row 1 as the reference row
This can be further utilized in conjunction with the index function to efficiently define dynamic named ranges, but this is something for another post as this is not related to the immediate question addressed herein.
I've tested the above methods with Excel 2010, both "natively" and in "Compatibility Mode" (for older versions of Excel) and they work. Again, with these you do not need to do any of the Ctrl+Shift+Enter. By leveraging the way sumproduct works in Excel we can get our arms around the need to carry array-operations but we do it without an array-formula. I hope someone out there may appreciate the beauty, simplicity and elegance of these proposed sumproduct solutions as much as I do. I do not attest to the memory-efficiency of the above solutions though. Just that they are simple, look beautiful, help the intended purpose and are flexible enough to extend their use to other purposes :)
Hope this helps!
All the best!
This works in Excel 2003 (& later with minor edit, see below). Press Ctrl+Shift+Enter (not just Enter) to enter this as an array formula.
=IF(ISBLANK(A65536),INDEX(A1:A65535,MAX((A1:A65535<>"")*(ROW(A1:A65535)))),A65536)
Be aware that Excel 2003 is unable to apply an array formula to an entire column. Doing so yields #NUM!; unpredictable results may occur! (EDIT: Conflicting information from Microsoft: The same may or may not be true about Excel 2007; problem may have been fixed in 2010.)
That's why I apply the array formula to range A1:A65535 and give special treatment to the last cell, which is A65536 in Excel 2003. Can't just say A:A or even A1:A65536 as the latter automatically reverts to A:A.
If you're absolutely sure A65536 is blank, then you can skip the IF part:
=INDEX(A1:A65535,MAX((A1:A65535<>"")*(ROW(A1:A65535))))
Note that if you're using Excel 2007 or 2010, the last row number is 1048576 not 65536, so adjust the above as appropriate.
If there are no blank cells in the middle of your data, then I would just use the simpler formula, =INDEX(A:A,COUNTA(A:A)).
An alternative solution without array formulas, possibly more robust than that of a previous answer with a (hint to a) solution without array formulas, is
=INDEX(A:A,INDEX(MAX(($A:$A<>"")*(ROW(A:A))),0))
See this answer as an example.
Kudos to Brad and barry houdini, who helped solving this question.
Possible reasons for preferring a non-array formula are given in:
An official Microsoft page (look for "Disadvantages of using array formulas").
Array formulas can seem magical, but they also have some disadvantages:
You may occasionally forget to press CTRL+SHIFT+ENTER. Remember to press this key combination whenever you enter or edit an array formula.
Other users may not understand your formulas. Array formulas are relatively undocumented, so if other people need to modify your workbooks, you should either avoid array formulas or make sure those users understand how to change them.
Depending on the processing speed and memory of your computer, large array formulas can slow down calculations.
Array Formula Heresy.
if you search in Column (A) use :
=INDIRECT("A" & SUMPRODUCT(MAX((A:A<>"")*(ROW(A:A)))))
if your range is A1:A10 you can use:
=INDIRECT("A" & SUMPRODUCT(MAX(($A$1:$A10<>"")*(ROW($A$1:$A10)))))
in this formula :
SUMPRODUCT(MAX(($A$1:$A10<>"")*(ROW($A$1:$A10))))
returns last non blank row number ,and indirect() returns cell value.
=INDEX(A:A, COUNTA(A:A), 1) taken from here
=MATCH("*";A1:A10;-1) for textual data
=MATCH(0;A1:A10;-1) for numerical data
Ive tried all the non-volatile versions but Not one version given above has worked.. excel 2003/2007update. Surely this can be done in excel 2003. Not as an array nor standard formula.
I either get just a blank, 0 or #value error.
So I resort to the volatile methods .. This worked..
=LOOKUP(2,1/(T4:T369<>""),T4:T369)
#Julian Kroné .. Using ";" instead of "," does NOT work! I think you are using Libre Office not MS excel?
LOOKUP is so annoyingly volitile I use it as a last resort only
For Microsoft office 2013
"Last but one" of a non empty row:
=OFFSET(Sheet5!$C$1,COUNTA(Sheet5!$C:$C)-2,0)
"Last" non empty row:
=OFFSET(Sheet5!$C$1,COUNTA(Sheet5!$C:$C)-1,0)
Place this code in a VBA module. Save. Under functions, User defined look for This function.
Function LastNonBlankCell(Range As Excel.Range) As Variant
Application.Volatile
LastNonBlankCell = Range.End(xlDown).Value
End Function
for textual data:
EQUIV("";A1:A10;-1)
for numerical data:
EQUIV(0;A1:A10;-1)
This give you the relative index of the last non empty cell in the range selected (here A1:A10).
If you want to get the value, access it via INDIRECT after building -textually- the absolute cell reference, eg:
INDIRECT("A" & (nb_line_where_your_data_start + EQUIV(...) - 1))
I had the same problem too. This formula also works equally well:-
=INDIRECT(CONCATENATE("$G$",(14+(COUNTA($G$14:$G$65535)-1))))
14 being the row number of the first row in the rows you want to count.
Chronic Clawtooth
I used HLOOKUP
A1 has a date;
A2:A8 has forecasts captured at different times, I want the latest
=Hlookup(a1,a1:a8,count(a2:a8)+1)
This uses a standard hlookup formula with the lookup array defined by the number of entries.
If you know that there are not going to be empty cells in between, the fastest way is this.
=INDIRECT("O"&(COUNT(O:O,"<>""")))
It just counts the non-empty cells and refers to the appropriate cell.
It can be used for a specific range as well.
=INDIRECT("O"&(COUNT(O4:O34,"<>""")+3))
This returns the last non empty cell in the range O4:O34.
This formula worked with me for office 2010:
=LOOKUP(2;1/(A1:A100<>"");A1:A100)
A1: the first cell
A100: refer to the last cell in comparing
I think the response from W5ALIVE is closest to what I use to find the last row of data in a column. Assuming I am looking for the last row with data in Column A, though, I would use the following for the more generic lookup:
=MAX(IFERROR(MATCH("*",A:A,-1),0),IFERROR(MATCH(9.99999999999999E+307,A:A,1),0))
The first MATCH will find the last text cell and the second MATCH finds the last numeric cell. The IFERROR function returns zero if the first MATCH finds all numeric cells or if the second match finds all text cells.
Basically this is a slight variation of W5ALIVE's mixed text and number solution.
In testing the timing, this was significantly quicker than the equivalent LOOKUP variations.
To return the actual value of that last cell, I prefer to use indirect cell referencing like this:
=INDIRECT("A"&MAX(IFERROR(MATCH("*",A:A,-1),0),IFERROR(MATCH(9.99999999999999E+307,A:A,1),0)))
The method offered by sancho.s is perhaps a cleaner option, but I would modify the portion that finds the row number to this:
=INDEX(MAX((A:A<>"")*(ROW(A:A))),1)
the only difference being that the ",1" returns the first value while the ",0" returns the entire array of values (all but one of which are not needed). I still tend to prefer addressing the cell to the index function there, in other words, returning the cell value with:
=INDIRECT("A"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1))
Great thread!
If you are not afraid to use arrays, then the following is a very simple formula to solve the problem:
=SUM(IF(A:A<>"",1,0))
You must press CTRL + SHIFT + ENTER because this is an array formula.
INDEX returns a value by index position in an array and ROWS then is used to specify the last position of the array.
=LET(array,A1:A10,INDEX(array,ROWS(array)))
Also works for multiple columns when setting the parameter [column_num] of INDEX to 0:
=LET(array,A1:C10,INDEX(array,ROWS(array),0))
A simple one which works for me:
=F7-INDEX(A:A,COUNT(A:A))
Okay, so I had the same issue as the asker, and tried both top answers. But only getting formula errors. Turned out that I needed to exchange the "," to ";" for the formulas to work. I am using XL 2007.
Example:
=LOOKUP(2;1/(A:A<>"");A:A)
or
=INDEX(A:A;MAX((A:A<>"")*(ROW(A:A))))
For version tracking (adding the letter v to the beginning of the number), I found this one to work well in Xcelsius (SAP Dashboards)
="v"&MAX(A2:A500)

Resources