There are questions how to determine the maximum of a mixed time-continuous and time-discrete signal x(t) over passed time with Modelica, i.e.,
y(t) = max{ x(s) with s in [startTime,t] }.
This is an open issue in the Modelica bug tracker (see https://trac.modelica.org/Modelica/ticket/109).
I will give a SimultionX-specific solution.
I am not sure what exactly last() does. But, from your description it seems to do the same the same thing as pre() in standard modelica. And this gives the same results in OpenModelica: