问题描述
我正在尝试添加一个使用多个If条件的新列,以检查特定列是否包含特定文本,数字设置为文本或文本值。
如果条件仅适用于前2个条件,但添加第3个检查条件,则对于以文本格式设置的数值不会产生所需的NULL结果。
===============================
Columntocheck | NewColumn
===============================
R0 | Questions
Is this my life? | Is this my life?
0.5445 | null
0.23 | null
0.23335 | null
===============================
公式为:
= Table.AddColumn(PrevIoUsstep,"NewColumn",each
if
Value.Is([Columntocheck],Text.Type) and not Text.Contains([Columntocheck],"R0") then
[Columntocheck]
else if
Text.Contains([Columntocheck],"R0",Comparer.OrdinalIgnoreCase) then
"Questions"
else if
Value.Is(Number.FromText([Columntocheck]),type number) then
null
else
null)
解决方法
也许您需要类似的东西
if
try Value.Is(Number.FromText([ColumnToCheck]),type number) otherwise Value.Is([ColumnToCheck],type number)
then
null
else
if
Value.Is([ColumnToCheck],Text.Type) and not Text.Contains([ColumnToCheck],"R0")
then
[ColumnToCheck]
else
if
Value.Is([ColumnToCheck],Text.Type) and Text.Contains([ColumnToCheck],"R0",Comparer.OrdinalIgnoreCase)
then
"Questions"
else
null
PQ中的结果看起来像