with( local!data: queryrecord( recordType: ri!recordName, query: 'type!{http://www.appian.com/ae/types/2009}Query'( 'selection|aggregation': 'type!{http://www.appian.com/ae/types/2009}Aggregation'( columns: { 'type!{http://www.appian.com/ae/types/2009}AggregationColumn'( field: "OrganizationCode", alias: "label", visible: true, isGrouping: true ), 'type!{http://www.appian.com/ae/types/2009}AggregationColumn'( field: "ClaimID", alias: "data", visible: true, aggregationFunction: "COUNT" ) } ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: - 1, sort: a!sortInfo( field: "label", ascending: true ) ) ) ).data, a!pieChartField( label: " Organization Code : Number of Letters ", series: apply( rule!ACP_GetPieChartSeries( label: _, data: _, saveInto: local!selectedCode << fn!append( _, "_2" ) ), merge( local!data.label, local!data.data ) ), showDataLabels: true, showTooltips: true ) )