function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex MakkAlex Makk 

Display Summary table that is grouped by 2 fields

Hello, I'm trying to figure out how to get the summary table that will break down data by building, then by the station. At the bottom of each group, it should show subtotals. The last row should display totals per table.

Here is what the end result should look like:
User-added imageHere is what I have now:
User-added image
Here is my controller:
public Map<String, StationListWrapper> getStationTracking() {
		Map<String, StationListWrapper> StationTracking = new Map<String, StationListWrapper>();
		if (logisticId != null) {
			List<Station_Tracking_Metrics__c> st = [SELECT Building_Area_Name__c, Name, Product_Name__c, Picked_Up__c, Delivered__c
			      FROM Station_Tracking_Metrics__c
			      WHERE EPUD__c = :logisticId];
			for(Station_Tracking_Metrics__c s: st){
				if(null == s.Building_Area_Name__c) continue;
					StationListWrapper wrapper = StationTracking.get(s.Name);
					if(wrapper == null){
						StationTracking.put(s.Name, new StationListWrapper(new List<Station_Tracking_Metrics__c>()));
		return StationTracking;
Here is my VF page component:
<apex:attribute name="LogId" type="String" description="Id of the EPUD" assignTo="{!logisticId}"/>
    <table  width="200px">
            <th>Picked Up</th>
    <apex:repeat value="{!StationTracking}" var="key">
        <apex:repeat value="{!StationTracking[key].stationList}" var="keyvalue">
                <td RowSpan="{!StationTracking[key].numOfStations}" Style="display:{!IF(CASESAFEID([key].firstOfList), 'table-data','none')};">{!}</td>
Please let me know if you have any ideas on how to achieve this. Thank you.