使用带 Text.Contains 的 IF 函数时预期获取令牌 Eof
Getting Token Eof Expected when using a IF function with Text.Contains
您好,我在尝试使用带有 Text.Contains 函数的嵌套 if 语句时遇到 'Token Eof Expected' 错误。
if Text.Contains([Status],"A") then "A"
else
Text.Contains([Status],"B") then "B"
else
"C"
所以我在这里尝试获取 'A' 如果 'A' 存在,则 'B' id 'B' 存在或 'C' 中的任何其他内容字符串。这里 'Status' 是我的 list/column.
PowerQuery 将第二个 then 突出显示为问题。
另一方面,下面的代码工作得很好。
if Text.Contains([Status],"A") then "A"
else "B"
我可以通过 3 个额外的步骤解决这个问题。
1st Step
if Text.Contains([Status],"A") then "A" else null
Outputs a column with name 'Status1'
2nd Step
if Text.Contains([Status],"B") then "B" else "C"
Outputs a column with name 'Status2'
3rd Step
if [Status1] = null then [Status2] else [Status1]
它完成了工作,但并不优雅。
感谢任何帮助。
谢谢
除了最后一个条件,需要在else
之后重复if
:
if Text.Contains([Status], "A") then
"A"
else if Text.Contains([Status], "B") then
"B"
else
"C"
您好,我在尝试使用带有 Text.Contains 函数的嵌套 if 语句时遇到 'Token Eof Expected' 错误。
if Text.Contains([Status],"A") then "A"
else
Text.Contains([Status],"B") then "B"
else
"C"
所以我在这里尝试获取 'A' 如果 'A' 存在,则 'B' id 'B' 存在或 'C' 中的任何其他内容字符串。这里 'Status' 是我的 list/column.
PowerQuery 将第二个 then 突出显示为问题。
另一方面,下面的代码工作得很好。
if Text.Contains([Status],"A") then "A"
else "B"
我可以通过 3 个额外的步骤解决这个问题。
1st Step
if Text.Contains([Status],"A") then "A" else null
Outputs a column with name 'Status1'
2nd Step
if Text.Contains([Status],"B") then "B" else "C"
Outputs a column with name 'Status2'
3rd Step
if [Status1] = null then [Status2] else [Status1]
它完成了工作,但并不优雅。
感谢任何帮助。 谢谢
除了最后一个条件,需要在else
之后重复if
:
if Text.Contains([Status], "A") then
"A"
else if Text.Contains([Status], "B") then
"B"
else
"C"