简体   繁体   English

PowerPivot计算列循环依赖性

[英]PowerPivot Calculated Column Circular Dependency

I'm really spinning my wheels on this one. 我真的在把我的轮子旋转。 I'm trying to add 2 calculated columns in a Power Pivot table (in Excel 2013) to a loaded single column. 我正在尝试将Power Pivot表(在Excel 2013中)中的2个计算列添加到已加载的单个列中。

Setup (just first row shown): 设置(仅显示第一行):

Prd | Beg                                                      | End
1   | =CALCULATE(SUM([End]),Table[Prd]=EARLIER([Prd])-1)       | =[Beg]+[Prd]

I want it to calculate like this: 我希望它这样计算:

Prd | Beg | End
1   | 1   | 2
2   | 2   | 4
3   | 4   | 7

But no matter what I do, I get a circular reference error because the [End] calculation is pointing to the [Beg] calculation and vice versa. 但是无论我做什么,都会得到循环引用错误,因为[End]计算指向[Beg]计算,反之亦然。 I'm trying to get it to perform a rolling calculation where the [Beg] amount always equals the [End] amount from the prior [Prd]. 我试图让它执行滚动计算,其中[Beg]数量始终等于先前[Prd]中的[End]数量。

I tried various calculations using SUMX and ALLEXCEPT, but I'm not getting this one right. 我使用SUMX和ALLEXCEPT尝试了各种计算,但是我没有得到正确的结果。 I even tried designating the Row Identifier in the Table Behavior tab based on this but it's not working with that either. 我什至尝试基于在“表行为”选项卡中指定“行标识符”,但它也不起作用。

Appreciate any suggestions! 感谢任何建议!

I would suggest you to base your formula for [Beg] column on previous values of [Prd] column. 我建议您将[Beg]列的公式基于[Prd]列的先前值。 Therefore 因此

Beg=SUMX(
         FILTER(  
                ALL(Table[Prd]),   
                Table[Prd] < EARLIER(Table[Prd])
               ),
         Table[Prd]
        ) + 1

Explanation : 说明
It sums up all the previous values for [Prd] column and adds 1 (if you take a look at the generated values, you'll see the pattern). 它将[Prd]列的所有先前值相加并加1(如果您查看生成的值,将会看到该模式)。


But the formula for [End] should also be fixed so you won't run into the same exception. 但是[End]的公式也应固定,这样您就不会遇到相同的异常。 So you'll have the following (this will sum values from current row for [Beg] and [Prd] ): 因此,您将具有以下内容(这将对[Beg][Prd]的当前行中的值求和):

End=SUMX(
         FILTER(
                ALL(Table[Beg], Table[Prd]), 
                Table[Prd]=EARLIER(Table[Prd])),Table[Beg]
        ) + Table[Prd]

Explanation : 说明
In your case, avoiding to use CALCULATE and using instead just SUMX and EARLIER for [End] will help you to get rid of circular dependency. 在您的情况下,避免使用CALCULATE并只对[End]使用SUMXEARLIER可以帮助您摆脱循环依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM