I don't understand why you think that that last value should be zero

With your function you simply connected two points by a straight line which also extends beyond the points

If your intention was that the function value should be zero for all values of s beyond 18 ft, you simply would have to add a third value larger than the last and with the very same function value.

Now you get

To automate what you did manually step by step you could create a vector containing the sum of all S-values up to

and use this vector of sums as function argument (vectorization not mandatory here but its good to be on the safe side)

To automate the 'Trib' values you could use

But for obvious reasons (every element is the arithmetic mean of the corresponding S-value and its successor but the last value in the S vecor has no successor) this vector has one element less than the rest and so you would not be able to multiply the 9-element vector with the 8-element vector Trib.
But you sure can multiply the first 8 values

Not sure if that's what you had in mind
maybe you wanted SSum to be used when calculating the Trib vector and not S.joist? You have to know what you need
Anyway, P9 sheet attached