M Query / Power Query if in / Expression.Error: We cannot apply an index of type List. Details

M Query / Power Query if in / Expression.Error: We cannot apply an index of type List. Details

我正在尝试使用以下 m 查询语言添加自定义列:

= if AccountType {{"I","E"}} then "IS" else "BS"

这是自定义列的屏幕截图:

如您所见,没有发现语法错误,但是,当我单击“确定”时,出现以下错误:

Expression.Error: We cannot apply an index of type List. Details: Value=[Table] Index=[List]

我查看了很多网站,但找不到解决此问题的方法。最接近的匹配是 this,但答案不是很清楚。

请帮忙。

这个有用吗

= if [AccountType] = "I" or [AccountType] = "E" then "IS" else "BS"

您也可以使用if List.Contains({"I","E"}, [AccountType]) then "IE" else "BS";或者如果列表实际上来自列,您可以将 {"I","E"} 替换为对列表列的引用,如 if List.Contains(tablename[columnname], [AccountType]) then "IE" else "BS";或者如果列表是实际列表,您可以将 {"I","E"} 替换为对实际列表的引用,如 if List.Contains(listname) then "IE" else "BS".