---
schema_version: "1"
id: 3f0fdec071f9de690e893975e929115a744cb52ea10f6e5b4056bd75f9b21f21
title: starts_with()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/reference/bi-saql-functions-string-sw.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-string-sw.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8ba23c23b66a45d8a541d0b3f0e08bd205f9a7b94774e03f982a32d6a026215a
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# starts_with()

Returns `true` if the string starts with the specified characters.

## Syntax

`starts_with(string, prefix)`

## Usage

Returns `true` if _string_ starts with _prefix_, otherwise returns `false`. String comparison is case-sensitive. If any of the parameters are `null`, then the function returns `null`. If _prefix_ is an empty string, then the function returns `null`.

## Example

Suppose that you want to count the opportunities where the owner role starts with "Sales". Use `starts_with()` in a `case` statement.

```nolang
q = load "DTC_Opportunity";

-- Select rows where the owner roles starts with "Sales"
q = foreach q generate count() as 'count', (case
 when starts_with('Owner_Role', "Sales") then 'Owner_Role'
end) as 'Owner_Role';

q = group q by 'Owner_Role';
q = foreach q generate count() as 'count', 'Owner_Role' as 'Owner_Role';
```

The resulting chart shows the number of opportunities where the owner role starts with "Sales", grouped by owner role.

![Number of opportunities where the owner ID starts with Sales.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_string_sw.png)
