AggregationProperty with dynamically generated table

Hi, I have a table created dynamically by code with a datasource of type: valueGroupDatasource also created by code. My question is if this is supported to create aggregation type “SUM”, I have the following code but I am throwing an error, what would be the correct way to do it ?:

Table laTabla = componentsFactory.createComponent (GroupTable.class);
LaTabla.setDatasource (ds);
LaTabla.setWidth ("100%");
LaTabla.setHeight ("100%");
laTabla.addAggregationProperty("compras", AggregationInfo.Type.SUM);

Where compras is a column of the table created dynamically by code.
Thanks and regards.


See this answer: Create a table dynamically with a datasource ValueGroupDatasourceImpl and KeyValueEntity - CUBA.Platform