You need to sign in to do that
Don't have an account?
![Jasjeet Grewal Jasjeet Grewal](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Need to compare fields data from two different objects
Hi everyone,
I have two objects Account and Sales.
Account has fields - name, created date, location, payment made.
Sales has fields - date, location, revenue.
I want to compare sum of all payment made by all accounts group by created date and location with revenue from sales object on particular date for same location.
for eg: 5 accounts from location A on Mar 01 has sum of 1000 as payment made.
Also on sales object location A on mar 01 should have revenue greater than 1000 or more.
I have tried reports, but I am not successful in getting it solved.
please suggest me possible ideas which I can use to implement this. I am comfortable using apex if needed.
I have two objects Account and Sales.
Account has fields - name, created date, location, payment made.
Sales has fields - date, location, revenue.
I want to compare sum of all payment made by all accounts group by created date and location with revenue from sales object on particular date for same location.
for eg: 5 accounts from location A on Mar 01 has sum of 1000 as payment made.
Also on sales object location A on mar 01 should have revenue greater than 1000 or more.
I have tried reports, but I am not successful in getting it solved.
please suggest me possible ideas which I can use to implement this. I am comfortable using apex if needed.
1. Create a wrapper class.
2. Query account Aggregate result to get sum of account based on created date and location.
3. Query Sales based on date and location.
4. Make a list of wrapper class and add the value and wrapper class.
5. Display data on Visualforce page.
6. On VF page you can visualize the data.
You can learn more about wrapper class here.
https://developer.salesforce.com/page/Wrapper_Class
Yes, wrapper class can be solution. But, my main concern is how will be able to use a single query to get data from 2 different objects.
From Account:
This query will give me result for Mar 12 and for all Locations.
Similarly, For Sales object: This query will give results for sales object.
But, what I wanted is use a single query to get results from both objects.
I would like a data such as following (layout could be little different)
Date Location Down Payment Total Revenue Total Revenue - Down Payment
2018-03-18 Location A 100 100 0
2018-03-18 Location B 150 100 50
Please, let me know how this could be possible.