简体   繁体   中英

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.

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. I'm trying to get it to perform a rolling calculation where the [Beg] amount always equals the [End] amount from the prior [Prd].

I tried various calculations using SUMX and ALLEXCEPT, but I'm not getting this one right. 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. 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).


But the formula for [End] should also be fixed so you won't run into the same exception. So you'll have the following (this will sum values from current row for [Beg] and [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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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