Forum Discussion
Circular dependency issue
Hi,
I'm trying to build a table in Power BI which includes a rolling sum columns,
but i have an issue of circular dependency.
I can build it in excel woth no problem.
The User2 formula is = IF(User = "User2" or User = "Both", CashFlow * 2230.05/Price * IF(User = "Both", User2Pct, 1), 0)
ex: User2 (row 6) = -650000*2230.05/2235.79*35.08% = -227409
But the User2Pct formula dependes on User2 column = Sum(User1) / Sum(User2) //(start till current row - 1)
ex: User2Pct (row 6) = Sum of User 1 rows 1-5 / Sum of User 2 rows 1-5
I have a measures that gives the user1 and user2, also a measure to User2Pct, but it's formula sum up the Raw columns before the multification with User2Pct - if we take the previous example it will sum the value of (-650000*2230.05/2235.79) / the same as for User1.
I can't figure out how to build it in power bi DAX.
Any help will be appreciated.
Regards,
Eran
Re
- 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
8 Replies
- v-huizhn-msftMicrosoft Employee
Hi Anonymous,
In the table, User2 use the User2Pct, and User2Pct use User2, its' weird? At first, I was considering there are no User2 and the User2Pct columns in your resource table? While you must create one column based on another one? So there must be one in the begginning, but both of them depands on each other, the logic is uncorrect. Because the calculation is based on columns rather than rows. Could you please share your resouce table for further analysis?
Best Regards,
Angelia- AnonymousNot applicable
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 logichttps://www.dropbox.com/s/ihkoptlrt376wmr/CircularDependencyEx.xlsx?dl=0
kind regards,
Eran- AnonymousNot applicable
Any Ideas?