DAX文字 - SEARCH函式



描述

返回特定字元或文字字串從左到右首次出現的字元位置。

搜尋不區分大小寫,但區分重音符號。

語法

SEARCH (<find_text>, <within_text>, [<start_num>], <NotFoundValue>) 

引數

序號 引數及描述
1

find_text

要查詢的文字。

您可以在find_text中使用萬用字元問號(?)和星號(*)。

問號匹配任何單個字元,星號匹配任何字元序列。

如果要查詢實際的問號或星號,請在字元前鍵入波浪號 (~)。

2

within_text

要在其中搜索find_text的文字,或包含文字的列。

3

start_num

可選。

要在within_text中開始搜尋的字元位置。

如果省略,預設為1。

4

NotFoundValue

當在within_text中找不到find_text時應返回的值。

可以是任何特定整數或 BLANK ()。

返回值

整數,如果指定為NotFoundValue則為空。

備註

  • DAX SEARCH函式不區分大小寫。搜尋“N”將找到'N'或'n'的第一次出現。

  • DAX SEARCH函式區分重音符號。搜尋“á”將找到'á'的第一次出現,但不會找到'a'、'à'或其大寫版本'A'、'Á'的任何出現。

  • 您可以使用SEARCH函式確定文字字串在另一個文字字串中的位置,然後使用MID函式返回文字,或使用REPLACE函式更改文字。

  • 如果在within_text中找不到find_text,則DAX SEARCH函式返回NotFoundValue(如果已給出)。如果省略,則返回#ERROR。

  • within_text中的空值將被解釋為空字串。

示例

= SEARCH ("Yes", "Yesterday",, BLANK()) returns 1. 
= SEARCH("yes","Yesterday") returns 1. 
= SEARCH ("no", "Yesterday",, BLANK()) returns (blank). 
= SEARCH("no","Yesterday") returns #ERROR. 
= MID("Yesterday",SEARCH("day","Yesterday"),2) returns da. 
= REPLACE("Yesterday",SEARCH("day","Yesterday"),3,"fff") returns Yesterfff. 
dax_functions_text.htm
廣告
© . All rights reserved.