Skip to main content

Summing values

Comments

3 comments

  • Permanently deleted user

    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
  • Permanently deleted user

    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
  • Berend Veldkamp

    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

Please sign in to leave a comment.