$NaN value in pavlovia even if PsychoPy references source Excel correctly

This is your issue. In Pavlovia you can’t edit spreadsheet variables. Try

loss2 = round(loss,2)

and then use loss2 in your msg.