Forum Discussion
Understanding DAX operator overloading
Hi pmscorca
It also depends on what’s on the other side of the operator.
For example, if you try to use the + operator between a number and a text string, you'll get an error.
But if the number is actually stored as text, and you try to concatenate it with another string, the engine treats both operands as text and performs concatenation.
So the operator behavior depends not only on the expected data type but also on the actual data types involved – and sometimes the result is determined by how the engine coerces types based on context.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
The addition (+ operator) between a number and a numeric string returns a numeric value according to the MS documentation: DAX tries to convert the numeric string in a number, because the expected operands of the additions have to be numeric; a such conversion is performed successfully because the actual numeric string can be converted in a number. For a text string as an addition operand, this implicit conversion fails.
So, a DAX operator respect to the expected operand data types affects the operator result and the operator behaviour doesn't change respect to the actual operand data types.
I think that in DAX it has no sense to talk about operator overloading: the behaviour of + operator doesn't change respect to actual text operands because it expects numeric operands.
Thanks