Power Query - 具有值的多个 OR 语句

Power Query - Multiple OR statement with values

我一直在研究这个,我发现了很多与文本相关的文章,但它们似乎对我不起作用。

为了说明这个公式有效,我只是想让它更有效率。我的公式看起来像: if [organization_id] = 1 or [organization_id] = 2 or [organization_id] = 3 then "North" else if … 其中 organization_id 的类型为 "WholeNumber"

我想通过执行以下操作来简化此操作: if [organization_id] in {1, 2, 3} then "North" else if …

我试过用圆括号、大括号和方括号括起来。似乎没有任何效果。大多数文章都使用某种形式的 text.replace 函数,而我的只是一个自定义列。

Power Query 中的 MCode 是否具有这样的效率,或者我是否必须像第一行一样写出每个单独的语句?

我已经成功使用 List.Contains 公式:

List.Contains({1,2,3}, [organization_id])

以上检查 [organization_id] 是否在第一个参数提供的列表中。

在某些情况下,您可能不想硬编码如上所示的列表,而是引用 table 列。例如,

List.Contains(TableWithDesiredIds[id_column], [organization_id])