Reputation: 1
I am very new to Power BI and I am trying to do a rankx to determine the ranking of instock % by vendors.
I have three columns: vendor, count, and instock. I created a third column below to calculate my instock % :
Instock % = CALCULATE(DIVIDE(sum('In Stock'[Instock]),SUM('In Stock'[Count])))
I then try the following to rank my vendors by their instock %, but return "A circular dependency was detected: In Stock[Instock %], In Stock[rank vendor], In Stock[Instock %]."
: rank vendor = RANKX(ALL('In Stock'[vendor]),'In Stock'[Instock %],,DESC)
What am I doing wrong?
Upvotes: 0
Views: 2725
Reputation: 1
Try
Measure rank vendor = RANKX(ALL('In Stock'),'In Stock'[Measure Instock %], DESC)
It's very frustrating!
Upvotes: 0
Reputation: 146
You need to user measures in this case to avoid circular dependencies.
First, instead of current calculated column Instock % you can create the measure with the same DAX you currently use for your column:
Measure Instock % = CALCULATE(DIVIDE(sum('In Stock'[Instock]),SUM('In Stock'[Count])))
Secondly, you can create a ranking measure, replacing the reference to calculated column from your original DAX with the reference to the new measure:
Measure rank vendor = RANKX(ALL('In Stock'[vendor]),'In Stock'[Measure Instock %],,DESC)
It works on my sample data.
Upvotes: 0