DataView and Compute

  • Thread starter Thread starter kevin
  • Start date Start date
K

kevin

Is there a way to perform a compute using a DataView that is already
Filtered?

I am trying to do some statistics on data from a dataset, grouping by day.
I have my DataView set up to filter out the appropriate range, project, etc.
I then want to compute a total of one field where DateComplete matches the
current day as I loop through each day. To do this, I want to call

dv.Table.Compute("Sum(Weight)", "CurrentDue >= #" & dStart & "# AND
CurrentDue <= #" & dStop & "#")

But, this seems to be eliminating my current fiter. Do I need to include
the current filter in the statement above? Is there a better / faster way
of making this data transformation? I would like to see better performce
than this hateful loop.

Also, since my DB values have Times in them as well, is there a way to avoid
the >= and <= that I have to use in another calculation where all I want to
do is match the day, not the day and time?

Thanks!

Kevin
 
Kevin:

..Computer is called on a DataTable not a view. In your code, dv.Table is
the same thing as referencing the datatable itslef. So if you had the
follwoing

DataView dv = myDataTable.DefaultView;

then dv.Table == myDataTable would be true. That's why you can sort on a
table's DefaultView and it won't affect the position of anything in the
table either. As such, there is no filter of the table that you are wiping
out b/c Compute is only dealing with the datable, not the view. Depending
on what the filter looks like, your best bet is to just add the filter
condition to the compute statement. Also, just for the sake of clarity, I'd
remove the reference to dv and just use DataTableName.Computer(...)

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
 
Back
Top