This could be the solution to your issue.
My line dataset had lines dissolved by an attribute, so that two (or more) lines in separate locations were merged (the dissolve command has an option for this or the merge command may have been used) to a single record of the attribute table.
When editing the vertices of such a record you can see the multiparts.
When you define the starting vertex (xat(0), yat(0)) of the line there are actually two. I think that this is where the error originates from.
A way to avoid this is to use the 'Explode lines' tool from the processing toolbox (from the "Processing" plugin) or the explode tool from the edit toolbar.
This will create a new record in your attribute table for every line segment meaning there is only one start and end vertex for each record.
I used this on my line dataset and the x- or yat or (0 "or-1" ) expressions worked without error.
After your calculations you can dissolve your lines again using any of the dissolve functions from the processing toolbox.