// appends measures
Iterator<CrosstabDefinition.Measure> measuresIt = measures.iterator();
while (measuresIt.hasNext()) {
CrosstabDefinition.Measure aMeasure = measuresIt.next();
IAggregationFunction function = aMeasure.getAggregationFunction();
String alias = getSQLAlias(aMeasure.getAlias(), baseQuery, baseQuerySelectedFields);
if (alias == null) {
// when defining a crosstab inside the SmartFilter document, an additional COUNT field with id QBE_SMARTFILTER_COUNT
// is automatically added inside query fields, therefore the alias is not found on base query selected fields
if (aMeasure.getEntityId().equals(QBE_SMARTFILTER_COUNT)) {
toReturn.append(AggregationFunctions.COUNT_FUNCTION.apply("*"));
} else {
logger.error("Alias " + aMeasure.getAlias() + " not found on the base query!!!!");
throw new RuntimeException("Alias " + aMeasure.getAlias() + " not found on the base query!!!!");
}
} else {
if (function != AggregationFunctions.NONE_FUNCTION) {
toReturn.append(function.apply(alias));
} else {
toReturn.append(alias);
}
}
if (measuresIt.hasNext()) {