none
multiply two text boxes in SSRS report

    Question

  • Hello Friends,

    textbox1 has expression and result comes in number.

    textbox2 has expression and result comes in number.

    textbox3, I need multiplication of textbox1 and textbox2.

    How can I achieve this?

    Thanks.

    Wednesday, September 25, 2013 3:32 PM

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.Value

    The 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 

    Thursday, September 26, 2013 5:59 AM
    Moderator

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.

    Wednesday, September 25, 2013 3:44 AM
  • Hi Mate,

    if you can send us a screen shot then that would be very help full.

    I have done a small test and it's multiplying correctly. Make sure you have taken correct textboxes as reprot items ?



    Dasari

    Wednesday, September 25, 2013 4:45 AM
  • 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/runningvalue-function-reporting.html

    Wednesday, September 25, 2013 5:03 AM
  •  

    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 day-night :)

    Thanks.



    Wednesday, September 25, 2013 11:25 AM
  • Wednesday, September 25, 2013 11:32 AM
  • Any help please? Thank you in advance ...
    Wednesday, September 25, 2013 12:19 PM
  • Write textbox3 expression as ,

    = ReportItems("textbox1").Value * ReportItems("textbox2").Value


    Regards, RSingh

    Wednesday, September 25, 2013 4:08 PM
  • Thank you but I am getting wrong answer of the multiplication. What should be wrong now?
    Wednesday, September 25, 2013 5:09 PM
  • 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.

    Thursday, September 26, 2013 1:02 AM
  • Show the screen shot of your report and the multiplication value.


    Regards, RSingh

    Thursday, September 26, 2013 5:14 AM
  • 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.

    Thursday, September 26, 2013 5:47 AM
  • 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.Value

    The 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 

    Thursday, September 26, 2013 5:59 AM
    Moderator
  • 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.


    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.

    Thursday, September 26, 2013 6:14 AM