Forum Discussion
Trying to divide two columns but getting error
Writing code, any code for that matter, requires from the author something that's called pedantry.
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.
2 Replies
- daXtreme
Solution Sage
Writing code, any code for that matter, requires from the author something that's called pedantry.
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. - v-yinliw-msft
Community Support
Hi Anonymous ,
According your code , you lost a “)” in the end of the first “table name[fieldname]”, in front of the minus.
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.