Sum
I am using FastReport VB.Net. I have created a simple report with several columns: Beginning Depreciation, Depreciation, and Ending Depreciation.
I want to have the total of Beginning Depreciation plus Depreciation appear in the column labeled Ending Depreciation for each row. See the PDF attachment.
I have been able to get a total for each column and show it in the bottom of the report. But I also want to do a simple adding of two of the column rows and enter it in the Ending Depreciation column.
And I don't know how to do that. This is something that should be real simple. I can do it with the ReportViewer like: sum([Beginning_Depreciation] + [Depreciation]). How is it done in Fast Reports?
I have right clicked on the Summation symbol and tried to enter sum([Beginning_Depreciation] + [Depreciation]), but I get an error message that Sum is not recognized.
What am I doing wrong? How is it supposed to be entered?
I want to have the total of Beginning Depreciation plus Depreciation appear in the column labeled Ending Depreciation for each row. See the PDF attachment.
I have been able to get a total for each column and show it in the bottom of the report. But I also want to do a simple adding of two of the column rows and enter it in the Ending Depreciation column.
And I don't know how to do that. This is something that should be real simple. I can do it with the ReportViewer like: sum([Beginning_Depreciation] + [Depreciation]). How is it done in Fast Reports?
I have right clicked on the Summation symbol and tried to enter sum([Beginning_Depreciation] + [Depreciation]), but I get an error message that Sum is not recognized.
What am I doing wrong? How is it supposed to be entered?
Comments
use reportscript :
and at reportsummary band, put textobject with expression [runTotal]
For example, there is a field called Beginning and another called Depreciation. I want to add the value of the field called Beginning to the value of the field called Depreciation and enter the total in a third field called Ending.
I do not want to add two column totals together. I want to add two individual fields together. This needs to be done for each row of the table. What would the code syntax for adding the two fields together and then putting the value in the field called Ending?
Any help with the code to accomplish this task will be greatly appreciated. Thank you so much.
I entered your suggested formula in the Ending TextObject and I get an error that says Error CS1525: Invalid expression term '
I am puzzled as to why it is so hard for me to find a reference in the Fast Report manual and on this forum board for the proper syntax to add together the values of two textobjects in the data band. It is very easy to do in Report Viewer. In Report Viewer the formula is simply:
=Sum(Field!Beginning.Value + Fields!Depreciation.Value)
Isn't there something similar to the Report Viewer formula above that can be entered in the Data Band of a Fast Report to do the same thing?
Any help with the syntax of a simple SUM function that can be entered in the Data Band of a Fast Report would be greatly appreciated.
Thanks
Beware with datasource, if your data source is MainReport then it should be : MainReport.Beginning_Depreciation] + [MainReport.Depreciation
I think you miss 'datasource dot'
Please attach your frx file, easier to find out the problem.
Thank you ipong,
The syntax that you suggested worked! Beginning_Depreciation] + [Depreciation
I entered it as text in a blank TextBox, and it worked just like I wanted it to. The trick was the extra brackets that enclosed the entire expression.
I was making the mistake of creating a New Total object and then entering the expression Beginning_Depreciation] + [Depreciation and I kept getting an error. I should have used a Textbox to enter the expression. I was also thinking that I needed the word SUM in the expression.
Thanks again,
BobV365