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
Anonymous
Not applicable

Trying to divide two columns but getting error

I'm new to DAX SORRY if this is a silly question. I'm trying to Divide two columns to find margin. 
Here's my intention 
(Column A-Column B)/Column A
 
What I wrote : 
Measure = DIVIDE(SUM('table name'[fieldname]-SUM('fieldname'), SUM('table name[(field name)])
 
Error I'm getting
The SUM function only accepts a column reference as an argument.
 
Thanks for your help!
1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

Writing code, any code for that matter, requires from the author something that's called pedantry.

daXtreme_0-1668792576090.png

Your code has an obvious problem:

Measure = DIVIDE(SUM('table name'[fieldname]-SUM('fieldname'), SUM('table name[(field name)])

Can you spot it? It's rather easy based on what the error message says. And it says:

The SUM function only accepts a column reference as an argument.
 
Column references in DAX are of the form 'Table'[ColumnName]. Measures, on the other hand, should never be preceded by the name of the table they reside in.
 
By the way, this form:
SUM('table name[(field name)])
might also be wrong if the field name is not originally surrounded with "(..)". What's more, you're missing the closing ' (apostrophe) here...
 
You have to write code exactly as the rules dictate. Otherwise, you'll be getting errors all over the place.

View solution in original post

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @Anonymous ,

 

According your code , you lost a “)” in the end of the first “table name[fieldname]”, in front of the minus.

vyinliwmsft_0-1669022278213.png

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

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

daXtreme
Solution Sage
Solution Sage

Writing code, any code for that matter, requires from the author something that's called pedantry.

daXtreme_0-1668792576090.png

Your code has an obvious problem:

Measure = DIVIDE(SUM('table name'[fieldname]-SUM('fieldname'), SUM('table name[(field name)])

Can you spot it? It's rather easy based on what the error message says. And it says:

The SUM function only accepts a column reference as an argument.
 
Column references in DAX are of the form 'Table'[ColumnName]. Measures, on the other hand, should never be preceded by the name of the table they reside in.
 
By the way, this form:
SUM('table name[(field name)])
might also be wrong if the field name is not originally surrounded with "(..)". What's more, you're missing the closing ' (apostrophe) here...
 
You have to write code exactly as the rules dictate. Otherwise, you'll be getting errors all over the place.

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.