# Len 스크립트 및 차트 함수

Len()은 입력 문자열의 길이를 반환합니다.

구문:

Len(text)

반환 데이터 유형: 정수

인수

| 인수 | 설명 |
| --- | --- |
| text | 평가할 문자열. |

예: 차트 표현식

| 예제 | 결과 |
| --- | --- |
| `Len('Peter')` | `5`를 반환합니다. |

## 예 - Len 기본 사항

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Len.htm)

#### 차트 표현식

개요

데이터 로드 편집기를 열고 새 섹션에 아래 로드 스크립트를 추가합니다.

로드 스크립트에는 다음이 포함됩니다.

* `Example`이라는 데이터 테이블에 로드되는 데이터 집합입니다.

* 데이터 테이블의 한 필드는 `CustomerComment`입니다. 필드에는 평가할 원본 텍스트 문자열이 들어있습니다.

로드 스크립트

```
Example:
Load  * inline [
CustomerComment
Please deliver after 5 PM.
Thank you for the quick service!
Can you add a gift wrap?
];
```

결과

데이터를 로드하고 시트를 엽니다. 새 테이블을 만들고 이 필드를 차원으로 추가합니다.

* ` CustomerComment
                                   `

다음 측정값을 만듭니다.

* `=Len(CustomerComment)`

결과 테이블

| CustomerComment | Len(CustomerComment) |
| --- | --- |
| Can you add a gift wrap? | 24 |
| Please deliver after 5 PM. | 26 |
| Thank you for the quick service! | 32 |

측정값 `Len(CustomerComment)`의 출력은 `CustomerComment` 입력 문자열의 길이를 반환합니다.

## 예 - Len 시나리오

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Len.htm)

#### 차트 표현식

개요

이 예에서는 각 주석의 길이를 깊이 또는 세부 수준의 표시기로 보고 고객 피드백을 분석합니다.

데이터 로드 편집기를 열고 새 섹션에 아래 로드 스크립트를 추가합니다.

로드 스크립트에는 다음이 포함됩니다.

* `Example`이라는 데이터 테이블에 로드되는 데이터 집합입니다.

* 데이터 테이블의 필드는 다음과 같습니다.

  * `TicketID`

  * `Description`

로드 스크립트

```
Example:
Load * inline [
TicketID, Description
1001, "I received the wrong product."
1002, "The package arrived damaged, and I would like a replacement."
1003, "I've been trying to reset my password for two days, and I haven't received an email."
1004, "My order status shows 'Delivered' but I have not received my package yet."
1005, "Is product XYZ available in size Large?"
1006, "I need help with an exchange for a faulty product, and I've attached photos."
];
```

결과

데이터를 로드하고 시트를 엽니다. 새 테이블을 만들고 다음 필드를 차원으로 추가합니다.

* ` TicketID
                                   `

* `Description`

다음 계산된 차원을 만듭니다.

* `=If(Len(Description) < 30, 'Short',If(Len(Description) <= 50, 'Medium', 'Long'))` 설명 길이에 따라 티켓에 대한 범주(Short, Medium, Long)를 계산하여 지정합니다.

결과 테이블

| TicketID | 설명 | If(Len(Description) &lt; 30, 'Short',If(Len(Description) &lt;= 50, 'Medium', 'Long')) |
| --- | --- | --- |
| 1001 | I received the wrong product. | Short |
| 1002 | The package arrived damaged, and I would like a replacement. | Long |
| 1003 | I've been trying to reset my password for two days, and I haven't received an email. | Long |
| 1004 | Is product XYZ available in size Large? | 중간 |
| 1005 | My order status shows 'Delivered' but I have not received my package yet. | Long |
| 1006 | I need help with an exchange for a faulty product, and I've attached photos. | Long |

계산 차원의 출력은 `Len` 함수를 사용하여 텍스트 문자열의 길이를 해석하여 데이터를 분류하는 방법을 보여 줍니다.

## 예 - 문자열 조작을 사용한 Len 시나리오

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Len.htm)

#### 차트 표현식

개요

데이터 로드 편집기를 열고 새 섹션에 아래 로드 스크립트를 추가합니다.

로드 스크립트에는 다음이 포함됩니다.

* `Example`이라는 데이터 테이블에 로드되는 데이터 집합입니다.

* 데이터 테이블의 한 필드는 `InputText`입니다.

로드 스크립트

```
Example:
Load  * inline [
InputText
this is a sample text string
capitalize first letter only
];
```

결과

데이터를 로드하고 시트를 엽니다. 새 테이블을 만들고 이 필드를 차원으로 추가합니다.

* ` InputText
                                   `

다음과 같이 계산 차원을 만듭니다.

* 

  ` =Upper(Left(InputText,1))  `는 텍스트 문자열의 첫 문자를 대문자로 변환합니다.

* 

  `=Mid(InputText,Len(upper(Left(InputText,1)))+1)`는 텍스트 문자열에서 첫 번째 문자를 제거합니다.

* 

  `=Upper(left(InputText,1)) & Mid(InputText,len(upper(left(InputText,1)))+1)`는 첫 번째 계산 차원의 출력과 두 번째 계산 차원의 출력을 결합합니다.

결과 테이블

| InputText | Upper(Left(InputText,1)) | Mid(InputText,Len(upper(Left(InputText,1)))+1) | Upper(left(InputText,1)) & mid(InputText,len(upper(left(InputText,1)))+1) |
| --- | --- | --- | --- |
| this is a sample text string | T | his is a sample text string | This is a sample text string |
| capitalize first letter only | C | apitalize first letter only | Capitalize first letter only |

첫 번째 계산 차원에서 ` Upper  ` 및 ` Left  ` 함수가 결합되어 `InputText`의 첫 문자를 대문자로 반환합니다. 두 번째 계산 차원에서 `Mid` 함수는 `Len` 함수를 사용하여 `InputText`에서 첫 번째 문자를 제거하는 텍스트 문자열을 반환합니다. 세 번째 계산 차원은 첫 번째와 두 번째 계산 차원을 결합하고 첫 번째 문자가 대문자인 `InputText` 문자열을 반환합니다.

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Len.htm)

#### 로드 스크립트

이 예에서는 차트 표현식 시나리오와 동일한 함수(Upper, Mid 및 Len)를 사용합니다. 로드 스크립트는 첫 문자가 대문자인 InputText를 반환하는 새 필드 NewInputText를 만듭니다.

```
Example:
Load InputText, First&Second as NewInputText;
Load *, mid(InputText,len(First)+1) as Second;
Load *, upper(left(InputText,1)) as First;
Load  * inline [
InputText
this is a sample text string
capitalize first letter only ];
```

결과 테이블

| InputText | NewInputText |
| --- | --- |
| this is a sample text string | This is a sample text string |
| capitalize first letter only | Capitalize first letter only |