Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

Sum of Dataset column

I have a data set called MyDataSet
Then i have a datatable called MyDataTable

I want to get the sum of column 3

How would I do this ?


Thank You
0
Vartana
Asked:
Vartana
  • 3
1 Solution
 
iboutchkineCommented:
Private Sub ComputeBySalesSalesID(ByVal myDataSet As DataSet)
    ' Presumes a DataTable named "Orders" that has a column named "Total."
    Dim myTable As DataTable
    myTable = myDataSet.Tables("Orders")
    ' Declare an object variable.
    Dim objSum As Object
    objSum = myTable.Compute("Sum(Total)", "EmpID = 5")
 End Sub
0
 
VartanaAuthor Commented:
I dont want to filter anything

How can i do it without filtering
0
 
iboutchkineCommented:
put criteria for filter that will match all the records.
FOr example you want to calculate quantity
objSum = myTable.Compute("Sum(Qty)", "Qty>0")
0
 
iboutchkineCommented:
also you can use Nothing for filter
objSum = myTable.Compute("Sum(Qty)", Nothing)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now