“Unlike in SQL, columns in the Select phrase do not actually exist until the final result table is returned. Thus a computed column cannot be used in other column expressions.”
You’ll need two different select statements here, e.g.
select (total+5)%total from select total:a+b from t
In q, the select statement operates in a manner that doesn't allow for the assignment of temporary variables within the select statement itself. Therefore, the behavior you're describing, where you can assign a temporary variable during select and reuse it within the same column, isn't supported.
The select statement in q typically operates on columns of a table or on the result of an expression, but it doesn't support intermediate assignment of variables like in some other programming languages.
To achieve the desired result, you may need to break down the calculation into separate steps or use functions to manipulate the data in the way you intend.