为什么对前一行中值的引用会抛出此 Expression.Error?

Why does a reference to a value in previous row throw this Expression.Error?

我正在尝试使用 Powerquery 在 Excel 中执行操作。

我想删除列表中的联系人,如果他们连接到某个 CompanyID 但列出的 CompanyName 不同。

第一步是通过与上面的行进行比较来过滤掉它们。它们总是连续列出。

下一步是删除删除列中包含值 delete 的所有行,但遗憾的是我没有执行该步骤。

我查看了 this post 并尝试使用以下代码:

= Table.AddColumn(#"Added index", "Delete", each if [CustomerID]= #"Added index"{[ContactID]-1}[CustomerID] and [CompanyName]<> #"Added index"{[ContactID]-1}[CompanyName] then "delete" else null)

但是我得到这个错误:

There were too many elements in the enumeration to complete the operation

我用谷歌搜索了这个错误,它似乎与重复的列名有关,但我没有这些。

请帮忙!

如果在 #"Added Index" 之后有任何操作数据的步骤,您需要注意当前步骤将引用出现在 #"Added Index" 步骤中的数据。您在 #"Added index" 步骤之后执行的任何操作将不适用于您发布的声明。

您可能需要调整发布的步骤以使用最新的数据表示而不是 #"Added index"

如果 #"Added index" 是您的 M 代码中的最新步骤,则语句运行良好,因此问题在于数据在中间的步骤中被操作。调整语句以引用最近的数据步骤而不是 #"Added index".