Custom report using ReportViewer

Rate It (1)

Last post 03-18-2008 4:17 PM by petaru. 10 replies.

Sort Posts:

  • Custom report using ReportViewer

    03-18-2008, 12:20 PM
    • Member
      2 point Member
    • wgg117
    • Member since 03-18-2008, 4:02 PM
    • Posts 59

    I have follow report to create using ReportViewer:

    ---------------------------------------------------------------------------------------------------------

    Buy/Sell               Date                Quantity              Price                 Net

    Buy                     12/12/2007         100                    11.6                7.90

    Sell                     12/13/2007          99                     11.8                7.80

                                    Totoal Buy:  100                  Total Buy Net      7.90

                                    Total Sell      99                   Total Sell Net      7.80       

                                    Total:          199                   Total Net            (0.1)

     ---------------------------------------------------------------------------------------------------------

    Total Net   = Total Sell Net - Total Buy Net

    I tried many ways, could not get what I wanted. The data source is object data source, not directly from database. Please help

     

    Thank you very much

             

  • Re: Custom report using ReportViewer

    03-18-2008, 12:51 PM
    • Member
      2 point Member
    • wgg117
    • Member since 03-18-2008, 4:02 PM
    • Posts 59

    I only have problem with the bottom part, the summary part :

    -----------------------------------------------------

                                    Totoal Buy:  100                  Total Buy Net      7.90

                                    Total Sell      99                   Total Sell Net      7.80       

                                    Total:          199                   Total Net            (0.1)

     --------------------------------------------------

     

    Thank you for your help !

  • Re: Custom report using ReportViewer

    03-18-2008, 1:00 PM
    • Participant
      1,801 point Participant
    • Corwin
    • Member since 11-30-2007, 3:01 PM
    • Ohio
    • Posts 340

    Are you able to write additional select stmts against the database?  Can you create other datasources?

    If so, build select stmts for the calculations you need, and add the needed text boxes to the bottom of your report for those values.

    Does that make sense?

    - Corwin
    (My Blog - www.ballhead.com/corwin)
  • Re: Custom report using ReportViewer

    03-18-2008, 1:23 PM
    • Member
      158 point Member
    • petaru
    • Member since 01-09-2008, 11:31 AM
    • Posts 45

    Create a table in Reporting Services.

    [Row Header:]

    Buy/Sell                  Date                        Qty.                    Price                    Net

    [Row Details:] 

    Buy                        12/12/2007               100                     11.6                      7.9

    Sell                        12/13/2007                99                      11.8                      7.8

    [Tip: Date format-- under format put "MM/dd/yyyy" for data type datetime.]

    [Row Footer: (this next part is using formulae that I would use to get it--)]

    Total Buy: =Sum(IIf((Fields!BuySell.Value) = "Buy", Fields!Quantity.Value, 0))

    Total Sell: =Sum(IIf((Fields!BuySell.Value) = "Sell", Fields!Quantity.Value, 0))

    Total: =Sum(Fields!Quantity.Value)

    [textbox name: txtTotalBuyNet]Total Buy Net: =Sum(IIf((Fields!BuySell.Value) = "Buy", Fields!Net.Value, 0))

    [textbox name: txtTotalSellNet]Total Sell Net: =Sum(IIf((Fields!BuySell.Value) = "Sell", Fields!Net.Value, 0))

    Total: =ReportItems!txtTotalBuyNet.Value - ReportItems!txtTotalSellNet.Value

     

    ----------------------------------------------------------------

    I am not SURE that this would work as I just typing and not validating >.>.... but it should give you a good idea how to approach this report :)

    Yay for figuring things out.
    (@.@)
  • Re: Custom report using ReportViewer

    03-18-2008, 1:50 PM
    • Member
      2 point Member
    • wgg117
    • Member since 03-18-2008, 4:02 PM
    • Posts 59

    Hi petaru,

    I tried , but Sum(IIf((Fields!BuySell.Value) = "Buy", Fields!Quantity.Value, 0)) gave me an error. seems not working.

    I changed it to Sum(IIf(Fields!BuySell.Value = "Buy", Fields!Quantity.Value, 0)), still gave me the error.

    Is this the way that does the comparision ?

    Thank you so much. 

     

  • Re: Custom report using ReportViewer

    03-18-2008, 2:02 PM
    • Member
      158 point Member
    • petaru
    • Member since 01-09-2008, 11:31 AM
    • Posts 45

    What did the error say?

    Yay for figuring things out.
    (@.@)
  • Re: Custom report using ReportViewer

    03-18-2008, 2:14 PM
    • Member
      2 point Member
    • wgg117
    • Member since 03-18-2008, 4:02 PM
    • Posts 59

    It did not say anything, just "#ERROR".

    If I put anything but "Buy" and" Sell" as the value to the expression (Buy and Sell are the only true values), it runs no error, but gave the 0 as the Sum result. It is supposed to have values

    It seems that if the comparision went through, Fields!Quantity.Value encounters some problem, right ?

     

    Thanks

  • Re: Custom report using ReportViewer

    03-18-2008, 3:22 PM
    • Member
      158 point Member
    • petaru
    • Member since 01-09-2008, 11:31 AM
    • Posts 45

    I got it now! 

    The following data types is what I used:

    BS = varchar(50)

    Net/Price = Decimal(18,2)

    ="Buy Total Qty: " & Sum(IIf((Fields!BS.Value) = "Buy", Fields!quantity.Value, 0))

    ="Sell Total Qty: " & Sum(IIf((Fields!BS.Value) = "Sell", Fields!quantity.Value, 0))

     ="Total Qty: " & Sum(Fields!quantity.Value)

    ="Buy Total Net: " & Sum(IIf((Fields!BS.Value) = "Buy", Fields!net.Value, 0.00d))

    ="Sell Total Net: " & Sum(IIf((Fields!BS.Value) = "Sell", Fields!net.Value, 0.00d))

     ="Total Net: " & (Sum(IIf((Fields!BS.Value) = "Buy", Fields!net.Value, 0.00d)) - Sum(IIf((Fields!BS.Value) = "Sell", Fields!net.Value, 0.00d))).toString

    Yay for figuring things out.
    (@.@)
  • Re: Custom report using ReportViewer

    03-18-2008, 3:24 PM
    • Member
      158 point Member
    • petaru
    • Member since 01-09-2008, 11:31 AM
    • Posts 45

    You should also read your Error List :)

     

    Ctrl + E in Visual Studio ^-^

    Yay for figuring things out.
    (@.@)
  • Re: Custom report using ReportViewer

    03-18-2008, 4:12 PM
    • Member
      2 point Member
    • wgg117
    • Member since 03-18-2008, 4:02 PM
    • Posts 59

    I think I may resolve the issue. I may need to put CDec before Fields!Some.Value.

    Thank you so much. Have a good afternoon !

  • Re: Custom report using ReportViewer

    03-18-2008, 4:17 PM
    • Member
      158 point Member
    • petaru
    • Member since 01-09-2008, 11:31 AM
    • Posts 45

    ^-^ I try to learn by resolving other people's issues.  I'm new to reporting services too.

    Yay for figuring things out.
    (@.@)
Page 1 of 1 (11 items)