检查一个字符串的任何部分是否与其他字符串的任何部分匹配
Check if any part of one string matches any part of other string
我正在寻找一种方法来检查一个字符串的任何部分是否在另一个字符串中。每个字符串都放在一个单独的列中,并包含一组随机代码。请参阅下面的示例。
该方法应检查原始故障列中的任何代码是否存在于当前故障列字符串中。如示例中所示,每个代码都是用一个 DI 和后面的 4 位数字创建的。每个原始代码都可以包含这些代码的随机数。现在我可以检查原始故障列中的整个字符串是否出现在当前故障列中,但我需要一个解决方案来检查当前故障列中原始故障列字符串中的每个单独代码细绳。如果至少有一个匹配项,它应该 return 在新列中选择是
这是我们如何使用 DAX 获取此信息的示例:
CheckIfTrue = VAR SplitByCharacter = " " VAR Org = SELECTEDVALUE(code[Orginal Faults]) VAR CurrentF = SELECTEDVALUE(code[Current Faults] ) VAR Table0 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", Org),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word])
VAR Table1 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", CurrentF),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word]) RETURN COUNTROWS(INTERSECT(Table0, Table1))+0 // Org
附加示例:
ShowError = VAR SplitByCharacter = " " VAR Org = SELECTEDVALUE(code[Orginal Faults]) VAR CurrentF = SELECTEDVALUE(code[Current Faults] ) VAR Table0 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", Org),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word])
VAR Table1 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", CurrentF),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word]) RETURN CONCATENATEX(INTERSECT(Table0, Table1),[Word],";") // Org
我正在寻找一种方法来检查一个字符串的任何部分是否在另一个字符串中。每个字符串都放在一个单独的列中,并包含一组随机代码。请参阅下面的示例。
该方法应检查原始故障列中的任何代码是否存在于当前故障列字符串中。如示例中所示,每个代码都是用一个 DI 和后面的 4 位数字创建的。每个原始代码都可以包含这些代码的随机数。现在我可以检查原始故障列中的整个字符串是否出现在当前故障列中,但我需要一个解决方案来检查当前故障列中原始故障列字符串中的每个单独代码细绳。如果至少有一个匹配项,它应该 return 在新列中选择是
这是我们如何使用 DAX 获取此信息的示例:
CheckIfTrue = VAR SplitByCharacter = " " VAR Org = SELECTEDVALUE(code[Orginal Faults]) VAR CurrentF = SELECTEDVALUE(code[Current Faults] ) VAR Table0 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", Org),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word])
VAR Table1 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", CurrentF),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word]) RETURN COUNTROWS(INTERSECT(Table0, Table1))+0 // Org
附加示例:
ShowError = VAR SplitByCharacter = " " VAR Org = SELECTEDVALUE(code[Orginal Faults]) VAR CurrentF = SELECTEDVALUE(code[Current Faults] ) VAR Table0 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", Org),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word])
VAR Table1 =
SELECTCOLUMNS(
ADDCOLUMNS (
GENERATE (
ROW ( "Text", CurrentF),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, MAX(TokenCount,1) )
),
"Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
),
"Word",[Word]) RETURN CONCATENATEX(INTERSECT(Table0, Table1),[Word],";") // Org