我不知何故无法弄清楚 IF 语句 Power Query M 中的列引用。
我想根据评估不同列上的字符串比较的条件替换列中的值。
= Table.TransformColumns(
#"Previous step",
{"Col_1", each if [Col_2] = "ghi" then null else _}
)
“Col_1” - 包含浮点数 Col_2 - 包含 4x 文本值
====================================================== ============= 在此示例中,如果 Col_2 中的字符串等于“ghi”,我想替换该值
Data:
Col_1 | Col_2
0 | abc
12 | def
100 | ghi
Expected result:
Col_1 | Col_2
0 | abc
12 | def
null | ghi
====================================================== ============= 请指教...
我尝试了不同的尝试,谷歌搜索,甚至是 chatGPT 3.5 ...以及该死的列引用。
Table.TransformColumns
无法交叉引用其他列。相反,您可以使用 Table.ReplaceValue
,例如:
= Table.ReplaceValue(
#"Previous step",
each [Col_1],
each if [Col_2] = "ghi" then null else [Col_1],
Replacer.ReplaceValue, {"Col_1"} )