---
schema_version: "1"
id: 7fb885de2b21b4ab89df405b7aa1d6016caf6ed768345f99f2282ce121282f97
title: first()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-fn-agg-1st.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-1st.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0cad8ad19eba3a52e16661d6270ef72daee602e6fe009509917399a4be391dad
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# first()

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.

**note:** If the values are not sorted, the 'first' value could be any value in the tuple.

## Example - Return the First Industry for an Account Owner

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.

```nolang
q = load "DTC_Opportunity_SAMPLE";
q = group q by ('Account_Owner', 'Industry');
q = foreach q generate 'Account_Owner' as 'Account_Owner', 'Industry' as 'Industry';
q = order q by 'Industry';

q = foreach q generate 'Account_Owner' as 'Account_Owner', first('Industry') as 'One Industry';
```

![Diagram showing first function with sorted field.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_fn_agg_1_sort.png)

## Example - Return Any Industry for an Account Owner

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.

```nolang
q = load "DTC_Opportunity_SAMPLE";
q = group q by 'Account_Owner';
q = 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).

![Diagram showing first function.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_fn_agg_1st.png)

**See Also**

- [last()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-last.md)
