This question runs in a pre-configured Salesforce environment - no personal connection required.
Write a method that creates a comprehensive contact report for multiple countries. The method should take a List of country names and return a Map<String, Map<String, Object>> where:
- The outer key is the country name
- The inner Map contains: 'contactCount' (Integer), 'totalRevenue' (Decimal), 'avgRevenue' (Decimal), and 'topContact' (String with name and title)
This advanced challenge tests your ability to combine complex SOQL queries, data aggregation, nested Map structures, and mathematical calculations across multiple objects and countries.
Examples
Input: countries = ['USA', 'Germany', 'Japan']
Output: {
'USA' => {
'contactCount' => 12,
'totalRevenue' => 450000000.00,
'avgRevenue' => 37500000.00,
'topContact' => 'David Thompson - Founder'
},
'Germany' => {
'contactCount' => 1,
'totalRevenue' => 75000000.00,
'avgRevenue' => 75000000.00,
'topContact' => 'Hans Mueller - Operations Director'
},
'Japan' => {
'contactCount' => 1,
'totalRevenue' => 65000000.00,
'avgRevenue' => 65000000.00,
'topContact' => 'Takeshi Yamamoto - CTO'
}
}
Explanation: Returns comprehensive country-level contact and revenue analysis
Input: countries = ['NonExistent']
Output: {}
Explanation: Returns empty map when no data exists for the countries
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Note
You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.