In the script, there is no Below() function. You can't get QlikSense to look ahead in your table input records.
You would need to create a table load that is sorted the other way round using ORDER BY, then use PEEK() or PREVIOUS() to compare ID with the line just read before.
if(ID = Previous(ID), 0, Weight) as [Corrected Weight]
ORDER BY Timestamp DESC; // adapt to a field you can use to order your table in reverse original order.