

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# endsWith
<a name="endsWith-function"></a>

`endsWith` 會評估表達式是否以您指定的子字串結尾。如果表達式以相應子字符串結束，則 `endsWith` 會返回 true，否則會返回 false。

## 語法
<a name="endsWith-function-syntax"></a>

```
endsWith(expression, substring, string-comparison-mode)
```

## 引數
<a name="endsWith-function-arguments"></a>

 *表達式*   
表達式必須是字串。它可以是使用字串資料類型的欄位、**'12 Main Street'** 之類的常值，或對輸出字串的另一個函數的呼叫。

 *substring*   
要針對表達式**檢查的字元集。該子字串在表達式**中可能出現一或多次。

 字串比較模式**   
(選用) 指定要使用的字串比較模式：  
+ `CASE_SENSITIVE`：字串比較區分大小寫。
+ `CASE_INSENSITIVE`：字串比較不區分大小寫。
空白時此值會預設為 `CASE_SENSITIVE`。

## 傳回類型
<a name="endsWith-function-return-type"></a>

Boolean

## 範例
<a name="endsWith-function-example"></a>

### 預設區分大小寫的範例
<a name="endsWith-function-example-default-case-sensitive"></a>

以下區分大小寫的範例評估 `state_nm` 是否以 **"York"** 結尾。

```
endsWith(state_nm, "York")
```

以下是指定欄位的值。

```
New York
new york
```

對於這些欄位值，會傳回以下值。

```
true
false
```

### 不區分大小寫的範例
<a name="endsWith-function-example-case-insensitive"></a>

以下不區分大小寫的範例評估 `state_nm` 是否以 **"york"** 結尾。

```
endsWith(state_nm, "york", CASE_INSENSITIVE)
```

以下是指定欄位的值。

```
New York
new york
```

對於這些欄位值，會傳回以下值。

```
true
true
```

### 條件陳述式範例
<a name="endsWith-function-example-conditional-statements"></a>

`endsWith` 函數可用作以下 If 函數中的條件陳述式：[avgIf](https://docs.aws.amazon.com/quicksight/latest/user/avgIf-function.html)、[minIf](https://docs.aws.amazon.com/quicksight/latest/user/minIf-function.html)、[distinct\$1countIf](https://docs.aws.amazon.com/quicksight/latest/user/distinct_countIf-function.html)、[countIf](https://docs.aws.amazon.com/quicksight/latest/user/countIf-function.html)、[maxIf](https://docs.aws.amazon.com/quicksight/latest/user/maxIf-function.html)、[medianIf](https://docs.aws.amazon.com/quicksight/latest/user/medianIf-function.html)、[stdevIf](https://docs.aws.amazon.com/quicksight/latest/user/stdevIf-function.html)、[stdevpIf](https://docs.aws.amazon.com/quicksight/latest/user/stdevpIf-function.html)、[sumIf](https://docs.aws.amazon.com/quicksight/latest/user/sumIf-function.html)、[varIf](https://docs.aws.amazon.com/quicksight/latest/user/varIf-function.html) 和 [varpIf](https://docs.aws.amazon.com/quicksight/latest/user/varpIf-function.html)。

以下範例僅當 `state_nm` 以 **"York"** 結尾時才對 `Sales` 求和。

```
sumIf(Sales,endsWith(state_nm, "York"))
```

### 不包含範例
<a name="endsWith-function-example-does-not-start-with"></a>

條件 `NOT` 運算子可用來評估表達式是否以指定的子字串開頭。

```
NOT(endsWith(state_nm, "York"))
```

### 使用數值的範例
<a name="endsWith-function-example-numeric-values"></a>

透過套用 `toString` 函數，可以在表達式或子字串引數中使用數值。

```
endsWith(state_nm, toString(5) )
```