Query Task to output statisics
Hi,
Has anyone used the Out Statistics in QueryTask workflow to query for summarized data? I want to find the maximum value in one column. I am trying to list "Group By Fields for Statistics" and "Out Fields" but it isn't working. Workflow posted below isn't crashing, it's just not grouping the data.
Thanks!
<Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="392,1238" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:eac="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client" xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:gce="clr-namespace:Geocortex.Core.Extensions;assembly=Geocortex.Core" xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi" xmlns:gfci="clr-namespace:Geocortex.Forms.Client.Items;assembly=Geocortex.EssentialsWpfApi" xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting" xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=System.Core" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=mscorlib" xmlns:s3="clr-namespace:System;assembly=System.ServiceModel" xmlns:s4="clr-namespace:System;assembly=System.Web.Services" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:sw="clr-namespace:System.Windows;assembly=PresentationFramework" xmlns:sw1="clr-namespace:System.Windows;assembly=WindowsBase" xmlns:sw2="clr-namespace:System.Windows;assembly=PresentationCore" xmlns:swt="clr-namespace:System.Windows.Threading;assembly=WindowsBase" xmlns:swt1="clr-namespace:System.Windows.Threading;assembly=System.Windows.Presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sap:VirtualizedContainerService.HintSize="352,1198" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Default="http://servername/rdosgis/rest/services/servicename/FeatureServer/3" Name="feeFeatureLayerURL" />
<Variable x:TypeArguments="x:String" Name="theToken" />
<Variable x:TypeArguments="esri:FeatureSet" Name="featureset" />
<Variable x:TypeArguments="scg2:IList(esri:OutStatistic)" Name="listStatisticsFields" />
<Variable x:TypeArguments="scg2:IList(x:String)" Name="listGroupByFields" />
<Variable x:TypeArguments="x:String" Default="username" Name="un" />
<Variable x:TypeArguments="x:String" Default="password" Name="pwd" />
<Variable x:TypeArguments="x:String" Default="http://servername/rdosgis/tokens/?" Name="tokenServiceURL" />
<Variable x:TypeArguments="x:String" Default="MaxID" Name="outFields" />
<Variable x:TypeArguments="x:String" Default="ID" Name="fieldName" />
<Variable x:TypeArguments="esri:OutStatistic" Default="[new OutStatistic("ID","MaxID",StatisticType.Max)]" Name="outStatistic" />
</Sequence.Variables>
<sap:WorkflowViewStateService.ViewState>
<scg2:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg2:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<gwa1:GenerateToken Expiration="10" sap:VirtualizedContainerService.HintSize="330,197" Password="[pwd]" Token="[theToken]" TokenServiceUrl="[tokenServiceURL]" UserName="[un]" />
<gwa1:CreateList x:TypeArguments="esri:OutStatistic" sap:VirtualizedContainerService.HintSize="330,59" Result="[listStatisticsFields]" />
<gwa1:InsertIntoList x:TypeArguments="esri:OutStatistic" sap:VirtualizedContainerService.HintSize="330,105" Index="0" Item="[outStatistic]" List="[listStatisticsFields]" />
<gwa1:CreateList x:TypeArguments="x:String" sap:VirtualizedContainerService.HintSize="330,59" Result="[listGroupByFields]" />
<gwa1:InsertIntoList x:TypeArguments="x:String" sap:VirtualizedContainerService.HintSize="330,105" Index="0" Item="[fieldName]" List="[listGroupByFields]" />
<gwa1:QueryTask GroupByFieldsForStatistics="[listGroupByFields]" sap:VirtualizedContainerService.HintSize="330,227" OutFields="[outFields]" OutStatistics="[listStatisticsFields]" QueryServiceUrl="[feeFeatureLayerURL]" Results="[featureset]" SpatialRelationship="esriSpatialRelIntersects" Token="[theToken]" />
<gwa1:Alert sap:VirtualizedContainerService.HintSize="330,82" Text="["Count: " & featureset.Features.Count() & " MaxID: " & featureset.Features(0).Attributes("MaxID").ToString()]" Title="Success" />
</Sequence>
</Activity>
-
Don't mean to dig up an old thread (you probably have this solved by now), but I encountered it while researching a similar task.
In the supplied workflow, the field "ID" (fieldName variable) is specified as the Group By fields for Statistics parameter for the Query Task, but it's also included in the outStatistic parameter. This causes all IDs to be returned since the query task was specified as "I want to group the IDs by unique IDs". If a different field (i.e. Name ) is specified for the Group By fields for Statistics parameter, the results should be grouped by Name, and the max ID for each unique Name value should be returned.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar