Forum Discussion
Circular dependency issue
- Anonymous8 years ago
Thanks,
I implemeted it with Power Query iventually, using function to get the running total and then use it in User1Pct and User2Pct.
Regards,
Eran
Hi Angelia,
thanks for your answer.
the logic is, if [User] column shows "User1" then the Discounted Cashflow belongs to User1 - Formula: [Cashflow] * [2230.05] / [Price]. the same logic when "User2"appears in [User] column. however when [User] column has "Both", the discounted cashflow of -650,000 which is -648,331 should be shared between them ProRata to the ratio prior to this transaction, thus if prior to a "Both" row the sum of all rows of User1 is 800 and the sum of all rows of user2 is 200, the User1Pct should be 80% and user2Pct 20%, and the "Both" row cashflow equals to 500, then the User1 should have 80% of 500, and User2 should have 20% of 500, (User1 400, User2 100), in our case the ratio for user1, 64.92% out of the -648,331 (-420,922) and 35.08% out of the -648,331 (-227,409)
i have attached a link to an excel sheet with this logic, the excel does not have a circular dependecy as the calculation is based on a cell rather than a column.
could you suggest how to implement this in current way or a better way to implement this logic
https://www.dropbox.com/s/ihkoptlrt376wmr/CircularDependencyEx.xlsx?dl=0
kind regards,
Eran
Any Ideas?
- v-huizhn-msft8 years agoMicrosoft Employee
Hi Anonymous,
I download your sample table and get the User column based on the PassDate, Crashflow and Prirce. After get User, we need to calculate User1 column, but User1 depands on User1Pct, but User1Pct has no value at first, how do you get value? For example: 739869=IF(OR(E4="Both",E4="User1"),C4/D4*$D$1*IF(E4="Both",H4,1),0), if there is H4 value, how do you calculate, it will return error?Please follow the steps to get user column.
1. Create a column using the formula:Column = VAR D=Table1[Row] RETURN CALCULATE(SUM(Table1[PassDate]),FILTER(ALL(Table1),Table1[Row]<=D))
2. Then create another calculated column using the formula.
User = IF(Table1[Column]=1,IF(Table1[Cashflow]<0,"Both","User2"),"User1")
Best Regards,
Angelia- Anonymous8 years agoNot applicable
Hi Angelia,
I fixed the User1Pct and User2Pct formulas:
User1Pct(first row) = IFERROR(SUM($H10:H$10)/SUM($H10:I$10), 1)
User2Pct(first row) =IFERROR(SUM($I10:I$10)/SUM($H10:I$10),0)
https://www.dropbox.com/s/ihkoptlrt376wmr/CircularDependencyEx.xlsx?dl=0
Regards,
Eran
- v-huizhn-msft8 years agoMicrosoft Employee
Hi Anonymous,
Hi Anonymous,
I got it. The first row of User1Pct is 1, User2Pct is 0. you calculated other rows based on the first row. The basic unit is the cell. But in Power BI we calculate based on column instead of cell or row.
At first, I thought I can set User1Pct=1, User2Pct=0, then create calculated columns.User1 = IF(OR(Table1[User]="Both",Table1[User]="User1"),Table1[Cashflow]/Table1[Price]*2230.05*IF(Table1[User]="Both",Table1[User1Pct],1),0)
User2 = IF(OR(Table1[User]="Both",Table1[User]="User2"),Table1[Cashflow]/Table1[Price]*2230.05*IF(Table1[User]="Both",Table1[User2Pct],1),0)
Then I try to fix User1Pct and User2Pct, we can't get expected result, which caused by Circular dependency issue. The basic unit in Power BI is column. So you'd better get expected result in excel, then can upload the result to Power BI desktop.
Best Regards,
Angelia
Best Regards,
Angelia