

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

# 在公式表達式中使用函數
<a name="expression-functions"></a>

您可以使用下列函數來操作公式表達式中的資料。

轉換和指標支援不同的 函數。下表指出哪些類型的函數與每種類型的公式屬性相容。

**注意**  
您可以在公式表達式中包含最多 10 個函數。


| 函數類型 | 轉換 | 指標 | 
| --- | --- | --- | 
| [在公式表達式中使用常見函數](expression-common-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用比較函數](expression-comparison-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用條件式函數](expression-conditional-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用字串函數](expression-string-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用彙總函數](expression-aggregation-functions.md) | <a name="polaris-no-para"></a>![A red circle with the letter x for no.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-no.png) 否 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用暫時函數](expression-temporal-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 
| [在公式表達式中使用日期和時間函數](expression-date-and-time-functions.md) | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | <a name="polaris-yes-para"></a>![A green circle with a checkmark for yes.](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/images/icon-yes.png) 是 | 

## 函數語法
<a name="expression-function-syntax"></a>

您可以使用下列語法來建立函數：

一般語法  
使用一般語法時，函數名稱後面接著具有零或多個引數的括號。  
`{{function_name}}({{argument1, argument2, argument3, ...}})`。 例如，具有一般語法的函數可能看起來像 `log(x)`和 `contains(s, substring)`。

統一函數呼叫語法 (UFCS)  
UFCS 可讓您在物件導向程式設計中使用 方法呼叫的語法來呼叫函數。使用 UFCS，第一個引數後面接著點 (`.`)，然後是函數名稱和括號內剩餘的引數 （如果有的話）。  
`{{argument1}}.{{function_name}}({{argument2}}, {{argument3}}, ...)`。 例如，搭配 UFCS 的函數可能看起來像 `x.log()`和 `s.contains(substring)`。  
您也可以使用 UFCS 鏈結後續函數。 AWS IoT SiteWise 會使用目前函數的評估結果做為下一個函數的第一個引數。  
例如，您可以使用 `message.jp('$.status').lower().contains('fail')`而非 `contains(lower(jp(message, '$.status')),'fail')`。  
如需詳細資訊，請造訪 [D 程式設計語言](https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs)網站。

**注意**  
您可以針對所有 AWS IoT SiteWise 函數使用 UFCS。  
AWS IoT SiteWise 函數不區分大小寫。例如，您可以`Lower(s)`互換使用 `lower(s)`和 。