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
JT Legal GroupJT Legal Group 

How to query data from a report

I have a report with list of clients with their name, email, date_added etc ... and would like to do a query from this report to get all clients where date_added is yesturday.

Is this possible? What is the best to do this? 

Thank you
Anne LewsonAnne Lewson
you should be able to use a value in the drop down for Account Created date and the value "yesterday" from the custom date  
this report will always select contacts of accounts that were Added (=created) yesterday  

range date set a yesterdayUser-added image
Raj VakatiRaj Vakati
You can use the report filter to filter the data as Anne Lewson said .. and export the data .. 

If you wanted to filter with SOQL its not possiable .. 

But you can doit with Apex Reporting API 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_analytics_run_reports.htm
Raj VakatiRaj Vakati
You can use apex to get the data  .. can you please explan what is your bussiness use case so i can able to give you correct solution 
 
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where 
    DeveloperName = 'Closed_Sales_This_Quarter'];
String reportId = (String)reportList.get(0).get('Id');

// Run a report
Reports.ReportResults results = Reports.ReportManager.runReport(reportId);

// Get the report metadata
Reports.ReportMetadata rm = results.getReportMetadata();
System.debug('Name: ' + rm.getName());
System.debug('ID: ' + rm.getId());
System.debug('Currency code: ' + rm.getCurrencyCode());
System.debug('Developer name: ' + rm.getDeveloperName());

// Get grouping info for first grouping
Reports.GroupingInfo gInfo = rm.getGroupingsDown()[0];
System.debug('Grouping name: ' + gInfo.getName());
System.debug('Grouping sort order: ' + gInfo.getSortOrder());
System.debug('Grouping date granularity: ' + gInfo.getDateGranularity());

// Get aggregates
System.debug('First aggregate: ' + rm.getAggregates()[0]);
System.debug('Second aggregate: ' + rm.getAggregates()[1]);

// Get detail columns
System.debug('Detail columns: ' + rm.getDetailColumns());

// Get report format
System.debug('Report format: ' + rm.getReportFormat());