Summing values
Total nubie here with no programming experience.
First off, I found another post that has an example of summing values from a QueryTask using a ForEach <Graphic> with an assign -- sum + Double.Parse(item.attributes("C1_SCHED").ToString()) but it doesn't work... Sigh.
Can someone please give me an example of a working sum for a selection from the Query Task? I usually don't have any problem figuring out workflow but this one is driving me insane!
Thank you,
JB
-
Hi bake 7734
Are you getting an error?
What was it?
Do you have a field in your QueryTask results called C1_SCHED?
Do you have values in that field that are unable to be converted to to a Double?
Have you declared a variable called sum to a Double DataType?
Regards
Ralph
0 -
Hi Ralph,
Thank you for the reply. I found that I could assign "sum + CType(item.attributes("C1_SCHED"), double)" to convert the number correctly.
JB
0 -
Just a small addition: If you have ArcGIS Server 10.1, and all you want is to do is calculate the sum of a field, but don't need the actual features, you can use the OutStatistics property of the QueryTask. Set it for instance to this value:
New List(Of OutStatistic) From { New OutStatistic("C1_SCHED", "SUM_SCHED", StatisticType.Sum) }
to get the summed values. The resulting featureset will have one column called 'SUM_SCHED', with one record containing the value. (You should also set 'Where' to some valid value, e.g. 0=0)
The advantage is that this works with any number of features, even if there are more than whatever the maximum number in the mapservice is set to.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare