How to add currencies in SSRS 2008 R2
Hi,
Can anyone tell how can I add value of two currencies from two different textboxes into third textbox.
For ex, i have 2 textboxes with each $10 value and i want to display its sum in third textbox (i.e. $20 (10+10))
I tried using below expression in resultant textbox(i.e. textbox3) field; but it does not seem to be working 100% as its giving #Error in some fields in output
=
ReportItems!Textbox1.Value
+
ReportItems!Textbox2.Value
Is it because if Data Conversion?
Thanks,
November 24th, 2010 11:14am
Try modifying your dataset query. Arithmetic computation is more efficiently performed in the database engine than the reporting front end.My Blog "Karl Beran's BI Mumble"
Free Windows Admin Tool Kit Click here and download it now
November 24th, 2010 11:54am
Hi Karl,
The "Total" field is not in the database; this is the calculated field I am adding based on the summation of currencies I have in the Textboxes1, 2.
And these Textboxes 1,2 are also I am getting by writing calculated expression. So, I have to fullfill the req. from reporting front-end only it seems.
Currently I am using this expression to get the total of currencies:
ReportItems!Textbox1.Value
+
ReportItems!Textbox2.Value
Any idea?
Thanks,
November 24th, 2010 12:02pm
I suppose you get #Error when one of the currency textbox value is NULL or impty.
try this
for text box one expression will be
=IIF(IsNothing(ReportItems!Textbox1.Value),0,ReportItems!Textbox1.Value)
For
textbox 2 -
=IIF(IsNothing(ReportItems!Textbox2.Value),0,ReportItems!Textbox2.Value)\
Keep
the third one as it is and now try
Gaurav Gupta http://sqlservermsbiblog.blogspot.com/
November 24th, 2010 2:04pm
Sorry for Typo Second Expression will be
=IIF(IsNothing(ReportItems!Textbox2.Value),0,ReportItems!Textbox2.Value)Gaurav Gupta http://sqlservermsbiblog.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
November 24th, 2010 2:05pm
Hi Gaurav,
I already tried using ISNOTIHNG expression, and now that #error part is resolved. am getting correct summation now.
Can you please let me know, if I want to display SUM of TEXTBOX3 (which is actaually summation of textbox1, 2 as mentioned in my above post). How can I do that, because when I used SUM function in that TEXTBOX3 field to display final total of all fields
from TEXTBOX3 it gave me an error "you cannot use aggregate function and aggregate function can only be used on report items that are contained within page headers or footers"
To sum up what I want to get is below:- I have,
TEXTBOX1 = $10
TEXTBOX2 = $20
TEXTBOX3 = $30 (sum of TEXTBOXES 1,2)
up to here I am getting everything working correctly..
now what can I do if i want to display summation of TEXTBOX3 in the row below of it. so, if I have in my TEXTBOX3 values $30, $40, $50 then it should give me summation of these fields =$120 in the Total row below. Any idea?
Thanks,
November 24th, 2010 3:43pm
Hi,
This problem is caused by aggregate ReportItem in the Report Body. By generally, we can use the aggregate function to aggregate a data field in the Report Body like
=Sum(Fields!fieldname.Value). However, as the error message shows, the aggregation of Report Items like
=Sum(ReportItems!TextBox3) can only be specified in Report Header or Footer.
In order to get the sum of TextBox3 in the Report Body, we need to add a calculated field for TextBox3. Please refer to the steps below:
1.
As you mentioned, the fields in TextBox1 and TextBox2 are calculated fields, so please add another calculated based on them.
For example, if the expressions of the calculated fields which specified to TextBox1 and TextBox2 are
=Expr1 and =Expr2, please add a calculated field
CalcField by the expression like
=IIf(IsNothing(Expr1),0,Expr1) + IIf(IsNothing(Expr2),0,Expr2)
2.
Specify the new calculated field to TextBox3 by the expression like
=Fields!CalcField
3.
Use the expression like
=Sum(Fields!CalcField) to get the sum.
Thanks,
Tony ChainPlease remember to mark the replies as answers if they help and unmark them if they provide no help
Free Windows Admin Tool Kit Click here and download it now
November 26th, 2010 2:37am
Hi Tony,
This is great, got it working, Thanks!!!
T
November 26th, 2010 11:53am