Calculated Insight: Vehicle Revenue From Dealer Sales

The Vehicle Revenue From Dealer Sales calculated insight aggregates the lifetime revenue generated for a specific vehicle by all dealerships. The vehicle revenue from dealer sales considers the approved claim amount for all dealers who sold and resold a specific vehicle.

Required Editions

Available in: Enterprise, Unlimited, and Developer Editions

Here’s a breakdown of the logic.

   
SELECT SUM(ssot__SalesOrderProduct__dlm.ssot__TotalPriceAmount__c) AS DirectAmount__c, ssot__Vehicle__dlm.ssot__VehicleIdentificationNumber__c AS VIN__c Applies the SUM aggregation function to the Total Price Amount field on the Sales Order Product object and assigns it an alias DirectAmount_c. Extracts the Vehicle Identification Number field from the Vehicle object and assigns it an alias VIN__c.
FROM ssot__SalesOrder__dlm JOIN ssot__SalesOrderProduct__dlm ON (ssot__SalesOrder__dlm.ssot__Id__c = ssot__SalesOrderProduct__dlm.ssot__SalesOrderId__c) Joins the Sales Order and Sales Order Product objects by matching the ID field on Sales Order to the Sales Order ID field on Sales Order Product.
JOIN ssot__Asset__dlm ON (ssot__SalesOrder__dlm.ssot__BillToAccountId__c = ssot__Asset__dlm.ssot__AccountContactId__c AND ssot__SalesOrderProduct__dlm.ssot__ProductId__c = ssot__Asset__dlm.ssot__ProductId__c) Joins the Sales Order and Asset objects by matching the Bill To Contact ID field on Sales Order to the Account Contact ID field on Asset. Joins the Sales Order and Asset objects by matching the Product ID field on Sales Order to the Product ID field on Asset.
JOIN ssot__Vehicle__dlm ON (ssot__Asset__dlm.ssot__VehicleId__c = ssot__Vehicle__dlm.ssot__Id__c) Joins the Asset and Vehicle objects by matching the Vehicle ID field on Asset to the ID field on Vehicle.
GROUP BY VIN__c Groups the results by VIN__c, aggregating the direct sales for each unique vehicle.