HOME DOCUMENTATION DOWNLOADS

Count(Count()) nested aggregation is not allowed

The following error occurs when the Count is used as an AggregationType type in field of an entity

2021-05-03 11:06:46,803 [27] ERROR Origam.ServerCore.Controller.AbstractController - Count(Count()) nested aggregation is not allowed. Use Sum(Count()) for a total nested count. Path: Entscheid/GewaltdelikteAnzahl (Parameter 'AggregationType')
Actual value was Count.
System.ArgumentOutOfRangeException: Count(Count()) nested aggregation is not allowed. Use Sum(Count()) for a total nested count. Path: Entscheid/GewaltdelikteAnzahl (Parameter 'AggregationType')
Actual value was Count.
   at Origam.DA.Service.AbstractSqlCommandGenerator.AggregationHelper(AggregatedColumn topLevelItem, DataStructureEntity topLevelEntity, AggregatedColumn item, Hashtable replaceParameterTexts, Int32 level, StringBuilder joins, Hashtable dynamicParameters, Hashtable parameterReferences) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 3090
   at Origam.DA.Service.AbstractSqlCommandGenerator.RenderExpression(ISchemaItem item, DataStructureEntity entity, Hashtable replaceParameterTexts, Hashtable dynamicParameters, Hashtable parameterReferences, Boolean renderSqlForDetachedFields) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 3058
   at Origam.DA.Service.AbstractSqlCommandGenerator.GetDataStructureColumnSqlExpression(DataStructure ds, DataStructureEntity entity, Hashtable replaceParameterTexts, Hashtable dynamicParameters, Hashtable selectParameterReferences, Boolean isInRecursion, Boolean& groupByNeeded, ColumnsInfo columnsInfo, DataStructureColumn column, String& groupExpression) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 2281
   at Origam.DA.Service.AbstractSqlCommandGenerator.RenderDataStructureColumn(DataStructure ds, DataStructureEntity entity, Hashtable replaceParameterTexts, Hashtable dynamicParameters, DataStructureSortSet sortSet, Hashtable selectParameterReferences, Boolean isInRecursion, Boolean forceDatabaseCalculation, String& group, SortedList`2 order, Boolean& groupByNeeded, ColumnsInfo columnsInfo, DataStructureColumn column, LookupOrderingInfo orderingInfo, FilterCommandParser filterCommandParser, OrderByCommandParser orderByCommandParser, Nullable`1 rowOffset) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 2186
   at Origam.DA.Service.AbstractSqlCommandGenerator.RenderSelectColumns(SelectParameters selectParameters, StringBuilder sqlExpression, StringBuilder orderByBuilder, StringBuilder groupByBuilder, Hashtable replaceParameterTexts, Hashtable selectParameterReferences, Boolean isInRecursion, Boolean concatScalarColumns, Boolean forceDatabaseCalculation, FilterCommandParser filterCommandParser, OrderByCommandParser orderByCommandParser) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 1812
   at Origam.DA.Service.AbstractSqlCommandGenerator.SelectSql(SelectParameters selectParameters, Hashtable replaceParameterTexts, Hashtable selectParameterReferences, Boolean restrictScalarToTop1, Boolean isInRecursion, Boolean forceDatabaseCalculation, FilterCommandParser filterCommandParser, OrderByCommandParser orderByCommandParser) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 1039
   at Origam.DA.Service.AbstractSqlCommandGenerator.BuildCommands(IDbDataAdapter adapter, SelectParameters selectParameters, Boolean forceDatabaseCalculation) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 335
   at Origam.DA.Service.AbstractSqlCommandGenerator.CreateDataAdapter(SelectParameters adParameters, Boolean forceDatabaseCalculation) in D:\a\1\s\Origam.DA.Service\Generators\AbstractSqlCommandGenerator.cs:line 166
   at Origam.DA.Service.AbstractDataService.GetAdapterNonCached(SelectParameters adParameters) in D:\a\1\s\Origam.DA.Service\AbstractDataService.cs:line 215
   at Origam.DA.Service.AbstractDataService.GetAdapterCached(SelectParameters adParameters, String identityId) in D:\a\1\s\Origam.DA.Service\AbstractDataService.cs:line 269
   at Origam.DA.Service.AbstractDataService.GetAdapter(SelectParameters selectParameters, UserProfile userProfile) in D:\a\1\s\Origam.DA.Service\AbstractDataService.cs:line 157
   at Origam.DA.Service.DataLoader.Fill() in D:\a\1\s\Origam.DA.Service\AbstractSqlDataService.cs:line 150
   at Origam.DA.Service.Profiler.ExecuteAndTakeLoggingAction(DataStructureEntity entity, Action loggingAction, Action actionToExecute) in D:\a\1\s\Origam.DA.Service\AbstractSqlDataService.cs:line 2693
   at Origam.DA.Service.AbstractSqlDataService.LoadDataSet(DataStructureQuery query, IPrincipal principal, DataSet dataset, String transactionId) in D:\a\1\s\Origam.DA.Service\AbstractSqlDataService.cs:line 372
   at Origam.DA.Service.AbstractSqlDataService.LoadDataSet(DataStructureQuery dataStructureQuery, IPrincipal principal, String transactionId) in D:\a\1\s\Origam.DA.Service\AbstractSqlDataService.cs:line 284
   at Origam.Workflow.DataServiceAgent.LoadData(DataStructureQuery query, DataSet data) in D:\a\1\s\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 140
   at Origam.Workflow.DataServiceAgent.Run() in D:\a\1\s\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 608
   at Origam.Workbench.Services.CoreServices.DataService.LoadData(Guid dataStructureId, Guid methodId, Guid defaultSetId, Guid sortSetId, String transactionId, QueryParameterCollection parameters, DataSet currentData, String entity, String columnName) in D:\a\1\s\Origam.Workbench.Services\CoreServices\DataService.cs:line 186
   at Origam.Workbench.Services.CoreServices.DataService.LoadData(Guid dataStructureId, Guid methodId, Guid defaultSetId, Guid sortSetId, String transactionId, QueryParameterCollection parameters) in D:\a\1\s\Origam.Workbench.Services\CoreServices\DataService.cs:line 149
   at Origam.ServerCommon.FormSessionStore.LoadCompleteData() in D:\a\1\s\Origam.ServerCommon\Session Stores\FormSessionStore.cs:line 188
   at Origam.ServerCommon.FormSessionStore.LoadDataFxServer() in D:\a\1\s\Origam.ServerCommon\Session Stores\FormSessionStore.cs:line 145
   at Origam.ServerCommon.FormSessionStore.LoadData() in D:\a\1\s\Origam.ServerCommon\Session Stores\FormSessionStore.cs:line 118
   at Origam.ServerCommon.FormSessionStore.Init() in D:\a\1\s\Origam.ServerCommon\Session Stores\FormSessionStore.cs:line 106
   at Origam.Server.UIManager.InitUI(UIRequest request, Boolean addChildSession, SessionStore parentSession, IBasicUIService basicUIService) in D:\a\1\s\Origam.ServerCommon\UIManager.cs:line 147
   at Origam.ServerCore.Controller.UIServiceController.<>c__DisplayClass9_0.<InitUI>b__0() in D:\a\1\s\Origam.ServerCore\Controller\UIServiceController.cs:line 113
   at Origam.ServerCore.Controller.AbstractController.RunWithErrorHandler(Func`1 func) in D:\a\1\s\Origam.ServerCore\Controller\AbstractController.cs:line 114

Please provide version of Origam.

This is a change we have recently made. You need to change your model as described in the error message as this is the only way how to model it so server side querying works.

EDIT: This error occurs when there is a nested aggregation in the model. E.g. Entity field MyCount1 as Count(Id) and then in another entity you have an entity field MyCount2 as Count(MyCount1). You have to use Sum on Count if you want to get total count of another count. So instead you should model Sum(MyCount1) which will give you a grand total count (sum of all counts).

The Origam Server version is 2021.1.1853.0

I suggested a feature to show an error already when in Architect.