# Mid - 脚本和图表函数

Mid() 返回从第二个参数“start”定义的字符位置开始的输入字符串的一部分，并返回第三个参数“count”定义的字符数量。如果省略“count”，则返回输入字符串的剩余部分。输入字符串的第一个字符的编号为 1。

语法：

Mid(text, start[, count])

返回数据类型： 字符串

参数：

参数

| 参数 | 说明 |
| --- | --- |
| text | 原始字符串。 |
| start | 定义 text 中要包含的第一个字符的位置的整数。 |
| count | 定义输出字符串的字符串长度。如果省略，则包含从 start 所定义位置开始的所有字符。 |

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

#### 示例：图表表达式

| 示例 | 结果 |
| --- | --- |
| `Mid('abcdef',3 )` | 返回“cdef” |
| `Mid('abcdef',3, 2 )` | 返回“cd” |

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

#### 示例：加载脚本

```
T1:
Load *, 
mid(Text,Start) as Mid1,           
mid(Text,Start,Count) as Mid2;    
Load * inline [
Text, Start, Count
'abcdef', 3, 2
'abcdef', 2, 3
'210714', 3, 2
'210714', 2, 3
]; 
```

结果

Qlik SenseQlik Sense 表显示了在加载脚本中使用 MidMid 函数的输出。

| Text | Start | Mid1 | Count | Mid2 |
| --- | --- | --- | --- | --- |
| abcdef | 2 | bcdef | 3 | bcd |
| abcdef | 3 | cdef | 2 | cd |
| 210714 | 2 | 10714 | 3 | 107 |
| 210714 | 3 | 0714 | 2 | 07 |

## 了解详情

* [Index - 脚本和图表函数](https://help.qlik.com/zh-CN/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/Index.htm)