To lookup the last value within one given row:
=LOOKUP(2;1/(Sheet1.42:42<>"");Sheet1.42:42)
which retuns the last value in row 42 on Sheet1.
If you have mixed text and numeric values within a row and want the last numeric value then
=LOOKUP(2;1/ISNUMBER(Sheet1.42:42);Sheet1.42:42)
All this needs at least LibreOffice 6.1 to work.
Update: 2019-06-25T20:38+02:00
To obtain the last 5 numeric values of one row use
=LOOKUP(LARGE(IF(ISNUMBER(Sheet1.42:42);COLUMN(Sheet1.42:42));{5,4,3,2,1});COLUMN(Sheet1.42:42);Sheet1.42:42)
entered as array formula (close with Shift+Ctrl+Enter instead of just Enter), it will then spread over 5 columns. Note that within the inline array {5,4,3,2,1}
the array column separator (here ,
comma) needs to be used, configured under Tools → Options → Calc → Formula, which depends on the locale. The formula returns #VALUE! error in all array elements if less than 5 numeric values are available.