StartWith
概述
StartWith 函数用于判断字符串是否以指定的子字符串开头。
语法说明
参数说明
| 参数 | 必需 | 参数类型 | 说明 |
|---|---|---|---|
| 字符串 | 是 | 字段、表达式、常量 | 需要检查的字符串 |
| 子字符串 | 是 | 字段、表达式、常量 | 用于匹配开头的子字符串 |
示例
筛选以特定前缀开头的产品名称
假设在一个产品数据表中,产品名称存储在名为 ProductName 的字段中。我们希望筛选出所有以 "Apple" 开头的产品名称,可以使用如下表达式:
示例公式
数据示例
| ProductID | ProductName |
|---|---|
| P001 | "Apple iPhone 13" |
| P002 | "Samsung Galaxy S21" |
| P003 | "Apple iPad Pro" |
| P004 | "Google Pixel 5" |
| P005 | "Apple Watch" |
计算结果
通过上述 StartsWith 函数表达式,结果将会是:
| ProductID | ProductName | StartWith |
|---|---|---|
| P001 | "Apple iPhone 13" | true |
| P002 | "Samsung Galaxy S21" | false |
| P003 | "Apple iPad Pro" | true |
| P004 | "Google Pixel 5" | false |
| P005 | "Apple Watch" | true |
该函数返回一个布尔结果,即判断字符串是否以指定的子字符串开头。在本示例中,StartWith(ProductName, "Apple") 用于筛选出所有以 "Apple" 开头的产品名称。