avg() or average()
count()
first()
last()
max()
median()
min()
sum()
unique()
stddev()
stddevp()
var()
varp()
percentile_cont()
percentile_disc()
regr_intercept()
regr_slope()
regr_r2()
grouping()
Windowing Functions
coalesce
Previous Versions
Returns the first value for the specified field.
Use first() to return the first value of a measure or dimension. You can also use first() used to return the value of a field without grouping by that field.
If the values are not sorted, the ‘first’ value could be any value in the tuple.
Note
Your reps own opportunities in several industries. You need a list of rep names with their first industry, where industry is sorted alphabetically. Group by account owner and industry, sort by industry, then use first() to get the first 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', first('Industry') as 'One Industry';
Your reps own opportunities in several industries. You need a list of rep names with any one of a rep’s industry - it doesn’t matter which one. In this case. Group by account owner then use first() to get the first industry from an unsorted collection.
1q = load "DTC_Opportunity_SAMPLE";
2q = group q by 'Account_Owner';
3q = foreach q generate 'Account_Owner' as 'Account_Owner', first('Industry') as 'One Industry';The resulting table displays each rep along with one of their industries (basically the first industry from an unsorted collection).

See Also