Forum Discussion
Functions for a calculated column
Hi
I want to create a calculated column for this table. I have 2 columsn and I want to add them and out the result in the calculated column. If I write this formula
= RoundTb[Amount] + RoundTb[bonus]
Everything is fine, but if i write this
=Sum(RoundTb[Amount] + RoundTb[bonus])
I get the message below. Does that mean for New Column, I can not use DAX function, only formulas? Thank you very much.
- Anonymous3 years ago
Hi lastnn30 ,
The SUM() function can contain only one column name.
The SUM() function adds up the values of the fields in the calculated column.
If you still want to use the SUM() function to return the value of each row, you can write like the following.
Column = CALCULATE(SUM('RoundTb'[Amount]),FILTER('RoundTb',[Amount]=EARLIER('RoundTb'[Amount])&&[bouns]=EARLIER(RoundTb[bouns])&&[item]=EARLIER(RoundTb[item])))In addition to the calculated column, there is also a measure that gives the result based on the context of the row.
Then measure and calculated columns sometimes return different results because the measure and the calculated column has a different row context.
Calculated Column and Measure in Power BI (powerbiconsulting.com)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- AnonymousNot applicable
Hi lastnn30 ,
The SUM() function can contain only one column name.
The SUM() function adds up the values of the fields in the calculated column.
If you still want to use the SUM() function to return the value of each row, you can write like the following.
Column = CALCULATE(SUM('RoundTb'[Amount]),FILTER('RoundTb',[Amount]=EARLIER('RoundTb'[Amount])&&[bouns]=EARLIER(RoundTb[bouns])&&[item]=EARLIER(RoundTb[item])))In addition to the calculated column, there is also a measure that gives the result based on the context of the row.
Then measure and calculated columns sometimes return different results because the measure and the calculated column has a different row context.
Calculated Column and Measure in Power BI (powerbiconsulting.com)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Ashish_MathurSuper User
Hi,
In the SUM formula, replace + with ,
- lastnn30Post Patron
Thanks a lot for your reply. It did not work! please see the screenshot below:
- Ashish_MathurSuper User
You are welcome. Read my reply again.