You'll want to define this at a lower level, so that it can be used in any expression, rather than just in a SELECT expression. Add it to the expression_term rule instead.