You can't use that in a SQL SELECT - everything after SQL to the end of the statement is passed to your DBMS to execute, and it cannot execute QV expressions.
Perhaps something like this - the preceding load will get the most recent and the SQL where clause will limit the search to dates after the fence in vDate:
Let vDate = '2015/07/01'; // this would be adjustable from a calendar object or input box
max(Date) As Date,
FirstSortedValue(Value, -Date) As Value
Group By Record_id;
SQL SELECT ID as Record_id,
Where Date >= '$(vDate)';
Note: format vDate in a way that is recognised by the DMBS, or use the DBMS CONVERT... or CAST... functions to convert to a suitable date value.
If you need this values for some expression, you can get them by making use of the function FirstSortedValue.
In order to apply descending sorting, your expression could be similar to the following:
If you need these values to be loaded in the data model instead of calculated, my suggestion would be to transpose the data into a different table and make use of one of the transposed columns to determine the value for each record.