for (String profileId : request.getProfileIds()) {
ProfileInstance profile = profileContextLocator.getProfileInstance(profileId);
report.addProfile(profile);
ProfileInstanceManager profileInstanceManager =
profileContextLocator.openProfileInstanceManager(profile);
Filter filterToUse = optionalFilter == null ? profile.getFilter() : optionalFilter;
Criterion filter = ReportUtils.buildFilter(filterToUse, specItem.getFilter());
List<ReportLineItem> reportData = profileInstanceManager.getReportData(
filter, specItem.getField(), specItem.getGroupByFields());
for (ReportLineItem reportLineItem : reportData) {
final List<String> groupByValues = reportLineItem.getGroupByValues();
final String groupKey = getStringListKey(groupByValues);