Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Create a Derived Measure
Example - Calculate the Time to Win
Suppose that you have an Opportunities dataset with the Close Date and Open Date fields. You want to see the number of days it took to win the opportunity. Use CloseDate_day_epoch and CreatedDate_day_epoch to create a derived measure called Time to Win: ('CloseDate_day_epoch'- 'CreatedDate_day_epoch') as 'Time to Win'.
The field Time to Win is calculated at run time:
1q = load "Opportunities";
2q = foreach q generate 'CloseDate_day_epoch' as 'CloseDate_day_epoch', 'CreatedDate_day_epoch' as 'CreatedDate_day_epoch', 'Opportunity_Name' as 'Opportunity_Name', ('CloseDate_day_epoch'- 'CreatedDate_day_epoch') as 'Time to Win';The resulting table contains the number of days to win each opportunity:
