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.

last()

Returns the last value in the tuple for the specified field.
Use last() to return the last value of a measure or dimension. You can also use last() to return the value of a field without grouping by that field.

If the values are not sorted, the 'last' value could be any value in the tuple.

Note

Example - Return the Last Industry for an Account Owner

Your reps own opportunities in several industries. You need a list of rep names with their last industry, where industry is sorted alphabetically. Group by account owner and industry, sort by industry, then use first() to get the last industry.

1q = load "DTC_Opportunity_SAMPLE";
2q = group q by ('Account_Owner', 'Industry');
3q = foreach q generate 'Account_Owner' as 'Account_Owner', 'Industry' as 'Industry';
4q = order q by 'Industry';
5
6q = foreach q generate 'Account_Owner' as 'Account_Owner', last('Industry') as 'One Industry';

Diagram showing first function with sorted field.