Based on Salesforce Documentation here , we may create cross-tabular report from the query result.
I've managed to create the class so far to show the aggregate result.
Apex Class
public class reportResource { class resultMatrix { public String Origin {get;set;} public String Status {get;set;} public Integer Count {get;set;} public resultMatrix(AggregateResult ar) { Origin = (String)ar.get('Origin'); Status = (String)ar.get('Status'); Count = (Integer)ar.get('Total'); } } public List getCaseMatrix() { List rm = new List(); for(AggregateResult result : [SELECT Origin, Status, COUNT(CaseNumber) Total FROM Case GROUP BY Origin, Status]) { resultMatrix objResultMatrix = new resultMatrix(result); rm.add(objResultMatrix); } return rm; } }
And the VF Page for the aggregate result
VF
<apex:page controller="reportResource" sideBar="false" standardStyleSheets="false"> <apex:form id="reportForm"> <apex:pageBlock title="Matrix Result"> <apex:pageBlockTable value="{!caseMatrix}" var="cm"> <apex:column headerValue="Incoming Origin" value="{!cm.Origin}"/> <apex:column headerValue="Case Status" value="{!cm.Status}"/> <apex:column headerValue="Number of Record" value="{!cm.Count}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
But, I don't know how to generate cross-tabular report like in the documentation.
Can anyone give me some clue how to build it?