Data: Report? Two SUM() Column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • weirdguy
    New Member
    • Jul 2009
    • 20

    Data: Report? Two SUM() Column

    Hello,

    I need advise on how to solve this scenario. I am not sure whether I should use any Report Application such as Crystal Report or I can just simply use datagridview.

    My scenario:
    In a new form, a table will show a least 3 columns.
    First, ItemID
    2nd, Total Quantity Sold for the Current Month
    3rd, Total Quantity Sold: Last month
    Code:
    ItemID     Current (Nov)     October
    ABA1          100              85
    ABB1          80               90
    Hence, I can compare the figure of the current month with the past few month.

    Right now, I do not have any problems building SQL_String for calculating the Total Qty Sold for the Current month and display it via DataGridView. But I am not sure how to additional column that calculate the Total for the past few month.

    Please advise. And thanks in advance.
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    You could use both. If you decide to use Crystal Reports, you can use a formula field to calculate the numbers and put in in a table. If you use a datagridview, you can use DataGridView.Co lumns.Add() and add the calculated numbers to that column. It's a matter of preference and design.

    Steven

    Comment

    • weirdguy
      New Member
      • Jul 2009
      • 20

      #3
      Thanks for your reply, Steven.

      Do you have any examples to explain further on the two solution?

      I had tried the Crystal Reports via Cross-Tab Report Wizard. It works fine.

      Right now, i would like to know how to use DataGridView like you mention.
      Should I use a Loop to calculate every ItemID?

      Comment

      • MrMancunian
        Recognized Expert Contributor
        • Jul 2008
        • 569

        #4
        You could use a for...next loop, but I think it's easier to change the query you use, put the data in a DataTable and bind the DataTable to the gridview.

        In case of the loop, bind the data to your datagridview first, then create a column, add it and the use the for...next to loop through your datagridview and fill the sumcolumn.

        Steven

        Comment

        Working...