You need to sign in to do that
Don't have an account?
Jacky Lee
Apex: Counting the number of groups in queried report data
Hi,
I have obtained the results of a report using apex. I'd like to retrieve the summary amounts for every record, but unsure how to find out the size, (i.e. count of groups in the report) in order to loop through the report.
According to the guide:
How can I find the size() of dim?
Thanks
I have obtained the results of a report using apex. I'd like to retrieve the summary amounts for every record, but unsure how to find out the size, (i.e. count of groups in the report) in order to loop through the report.
According to the guide:
List<Report> reportList = [SELECT Id, DeveloperName FROM Report WHERE Id = 'report ID here']; String reportId = (String)reportList.get(0).get('Id'); Reports.reportResults results = Reports.ReportManager.runReport(reportID, true); Reports.Dimension dim = results.getGroupingsDown(); Reports.GroupingValue groupingVal = dim.getGroupings()[0]; System.debug('Key: ' + groupingVal.getKey()); System.debug('Label: ' + groupingVal.getLabel());
How can I find the size() of dim?
Thanks
Aggregate Functions will help you ro solve this problem
follow the below link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_agg_fns.htm