You need to sign in to do that
Don't have an account?
Mathew Andresen 5
split a list into sub groups (maps)
Hi,
I have a list that I want to split up into seperate sub groups. Basically it's an aggregate result list that I want to split up by account name, and then time period (which I define as a string of year plus quarter). Here is what I have so far, but I have to think there's a better way.
Thanks,
I have a list that I want to split up into seperate sub groups. Basically it's an aggregate result list that I want to split up by account name, and then time period (which I define as a string of year plus quarter). Here is what I have so far, but I have to think there's a better way.
Thanks,
Map<string, Decimal> amountMap = new Map<String, Decimal>(); string lastname; string name; string accountId; try { for (AggListWrapper wrapper:wrapperList) { name = wrapper.name; accountId = wrapper.accountId; decimal amount = wrapper.amount; string periodYear = ''+ wrapper.year + '-' + wrapper.period; periodYearSet.add(periodYear); if (lastName == NULL) { lastName=name;} if (lastName != name) { completeRowList.add(new PivotRowWrapper(lastName, accountId, amountMap, NULL)); amountMap = new Map<string, Decimal>(); } amountMap.put(periodYear, amount); system.debug('PivotTimeSeries_Class *** account id = ' + accountId + 'end of loop name=' + name + ' lastName=' + lastName + ' amountMap=' + amountMap); lastName = name; } } catch (exception e) { system.debug('PivotTimeSeries_Class *** error in the wraperList lopp ' + e); } periodYearList.addAll(periodYearSet); periodYearList.sort(); completeRowList.add(new PivotRowWrapper(name, accountId, amountMap, NULL)); // line total is null when we first go through
This will generate a map that you can travers using the sortedAccountNames list. If this doesn't help you, please help me understand your code and include the missing class definitions and possibly the usage of this code (Visualforce page?)
All Answers
This will generate a map that you can travers using the sortedAccountNames list. If this doesn't help you, please help me understand your code and include the missing class definitions and possibly the usage of this code (Visualforce page?)
Thanks,