Forum Discussion

smore's avatar
smore
Advocate I
5 years ago

Using a RANKX values as Y-Axis in Stacked Bar Chart

I have a field Table with columns Tree # and Apple Diameter. I want to rank the apples by largest diameter based on a slicer selection of whichever Tree # is selected. The final visual is a Stacked Bar Chart with Rank # on the Y-axis and Diameter on the X-axis.

I created a measure to Rank based on Diameter:

Rank Measure  =

RANKX(

          ALLSELECTED('Table1),

          CALCULATE(SUM(‘Table'[Diameter]))

          ,, DESC

)

This measure works in a Table Visual with the rank changing based on whichever Tree # is selected but Power BI Desktop does not allow me set the Rank measure as the Y-Axis in my Stacked Bar Chart. I can only add the RANK measure in the VALUES field of the bar chart. How do I work around this?

I tried creating a calculated column in Table 1 with using the DAX from the Rank Measure posted above but I receive the error :"A circular dependency was detected: Table1[RankColumn]."

So far: I can use a calculated column on Table1 as the Y-axis but cannot get the Rank working. I have a Rank Measure working but cannot use it as a Y-axis. Please help. Thanks.