Answered by:
multiply two text boxes in SSRS report
Question
Answers

Hi Database,
According to your description, it seems that this issue occurs when you attempt to multiply two text boxes which have their own expressions in SSRS report, while you get a wrong answer in textbox3. After testing it in my own environment, it works well. So it is hard to give you the exact solution to solve this issue base on your description.
The following steps which I tested is for your reference:
1. Create a DataSet named DataSet1 with the following query statement:
CREATE TABLE #temp(Year1 int, Year2 int, Year3 float) INSERT INTO #temp VALUES (12,800,10.4), (8,812,12.57) SELECT * FROM #temp
2. Drag a textbox named textbox1 with the expression below to design surface:
=Sum(Fields!Year1.Value, "DataSet1") * Sum(Fields!Year2.value, "DataSet1")
3. Drag a textbox named textbox2 with the expression below to design surface:
=Sum(Fields!Year3.Value,"DataSet1")
4. Drag a textbox named textbox3 with the expression below to design surface:
=ReportItems!Textbox1.Value * ReportItems!Textbox2.ValueThe following screenshot is for your reference:
Design surface:
Result:Maybe I simplify the problem which you occurred, so please provide us more information about the report. So that we can make further analysis and help you out.
Thank you for your understanding.
Thanks,
Katherine Xiong Marked as answer by Katherine XiongMicrosoft contingent staff, Moderator Monday, October 07, 2013 1:18 AM
All replies

Hello Friends,
Multiplication of two text boxes coming wrong in third text box, what am I doing wrong here?
Third text box has following expression:
=ReportItems!stageLengthAVGMD83ByYear2.Value * ReportItems!yeildMD83ByYear.Value
Please help. The multiplication appears to be wrong.
Thanks.
 Merged by Katherine XiongMicrosoft contingent staff, Moderator Monday, September 30, 2013 5:59 AM duplicate thread


You may need to use the running value for this purpose.
Check the below link on how to use it.
http://mangalpardeshi.blogspot.com.au/2009/03/runningvaluefunctionreporting.html

I am getting t3 incorrect if you multiply t1 and t2.
please look that screenshot ... text boxes are in number with 1000 separator. All textboxes have their own expressions.
T1 Expression: =Sum(Fields!Year1.Value, "SearchDate") * Sum(Fields!Year2.value, "SearchDate")
T2 Expression: =Sum(Fields!Year3.Value, "SearchDate")
T3 Expression which does T1*T2: =Sum(Fields!Year1.Value, "SearchDate") * Sum(Fields!Year2.value, "SearchDate") * Sum(Fields!Year3.Value, "SearchDate")
Please help. I am trying to figure out since a daynight :)
Thanks.
 Edited by Database Junior Wednesday, September 25, 2013 11:32 AM



Write textbox3 expression as ,
= ReportItems("textbox1").Value * ReportItems("textbox2").Value
Regards, RSingh
 Proposed as answer by Alisa TangMicrosoft contingent staff, Moderator Thursday, September 26, 2013 9:24 AM


Are you computing the date column in the T1 and T2 and multiplying it in T3??
I suppose you can't multiply date value, which is practically not possible.
T1 Expression: =Sum(Fields!Year1.Value, "SearchDate") * Sum(Fields!Year2.value, "SearchDate")
T2 Expression: =Sum(Fields!Year3.Value, "SearchDate")
T3 Expression which does T1*T2: =Sum(Fields!Year1.Value, "SearchDate") * Sum(Fields!Year2.value, "SearchDate") * Sum(Fields!Year3.Value, "SearchDate")
If you are not calculating based on date then what is the desired outcome of the T3 column.


Take the expression from textbox 1, and the expression from textbox 2, put the two expressions in your textbox 3 with a multiplier between them.
You really need to post your report layout and your expressions and some example data though for us to help more.

Hi Database,
According to your description, it seems that this issue occurs when you attempt to multiply two text boxes which have their own expressions in SSRS report, while you get a wrong answer in textbox3. After testing it in my own environment, it works well. So it is hard to give you the exact solution to solve this issue base on your description.
The following steps which I tested is for your reference:
1. Create a DataSet named DataSet1 with the following query statement:
CREATE TABLE #temp(Year1 int, Year2 int, Year3 float) INSERT INTO #temp VALUES (12,800,10.4), (8,812,12.57) SELECT * FROM #temp
2. Drag a textbox named textbox1 with the expression below to design surface:
=Sum(Fields!Year1.Value, "DataSet1") * Sum(Fields!Year2.value, "DataSet1")
3. Drag a textbox named textbox2 with the expression below to design surface:
=Sum(Fields!Year3.Value,"DataSet1")
4. Drag a textbox named textbox3 with the expression below to design surface:
=ReportItems!Textbox1.Value * ReportItems!Textbox2.ValueThe following screenshot is for your reference:
Design surface:
Result:Maybe I simplify the problem which you occurred, so please provide us more information about the report. So that we can make further analysis and help you out.
Thank you for your understanding.
Thanks,
Katherine Xiong Marked as answer by Katherine XiongMicrosoft contingent staff, Moderator Monday, October 07, 2013 1:18 AM

try this
=CDbl(Fields!T1.Value) * CDbl(Fields!T2.Value)
Thanks, Mohan Kumar  www.sqlvillage.com  Please mark the post as answered if it answers your question.
 Edited by Mohan Kumar  DataPlatformExperts.com Thursday, September 26, 2013 6:10 AM

following should return correct value:
=CInt(Fields!TextBox1.Value) * CInt(Fields!TextBox2.Value)
I have assumed integer value if you have double or something else then use appropriate function.For example: CDbl for double.
Thanks, Mohan Kumar  www.sqlvillage.com  Please mark the post as answered if it answers your question.