Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
pmscorca
Post Prodigy
Post Prodigy

Understanding DAX operator overloading

Hi,

I've read that DAX supports the operator overloading.

Operator overloading in computer programming is the process of defining custom behaviors for operators like +, -.

So, a same operator could be overloaded to work with an integer and a string.

But how does DAX support the operator overloading? Does the operator result depend on the operator data type or the data type of the operands?

I'd like to understand better the DAX operator overloading.

Thanks

9 REPLIES 9
Anonymous
Not applicable

Hi @pmscorca,

I wanted to follow up since we haven't heard back from you regarding our last response. We hope your issue has been resolved.
If the community member's answer your query, please mark it as "Accept as Solution" and select "Yes" if it was helpful.
If you need any further assistance, feel free to reach out.

Please continue using Microsoft community forum.

Thank you,
Pavan.

Anonymous
Not applicable

Hi @pmscorca,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please "Accept  as  Solution" and give a 'Kudos' so other members can easily find it.

Thank you,
Pavan.

Anonymous
Not applicable

Hi @pmscorca,

Thank you for reaching out in Microsoft Community Forum.

Thank you @lbendlin@Ritaf1983    for the helpful response.

As suggested by Ibendlin and Ritaf1983,  I hope this information was helpful. Please let me know if you have any further questions or you'd like to discuss this further. If this answers your question, please "Accept as Solution" and give it a 'Kudos' so others can find it easily.

Please continue using Microsoft community forum.

Regards,
Pavan.

Ritaf1983
Super User
Super User

Hi @pmscorca 
DAX doesn't support operator overloading in the traditional object-oriented sense, but it does define different behaviors for the same operator based on the operand types.
For example, + / - works for  numberical data types and also for adding days to a date.
However, DAX doesn't use + for strings – it uses & for string concatenation.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Ok, but does the operator result depend on the operator data type (or better the expected data type of the operands) or the real data type of the operands?

The + operator expects numeric operands; if numeric strings are used, this operator continues to return a numeric result.

The & operator expects alphanumeric operands; if numeric strings are used, this operator raises an error.

It seems that it drives the expected operand data type without overriding the operator behaviour, isn't it?

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.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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

Here's a fun one.  Calculated column, but works with measures too

 

Column =
var y = 2025
return "FY" & y
lbendlin
Super User
Super User

For example:  TODAY()+1

for date math

 

Or:  {1}

for table math

 

Or: CONCATENATEX(table,[column])

for table to scalar math

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors