Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Rankx dax function in column with complicated measure

 am having an issue with using the rankx function in a column in my table. I can calculate the rank with a measure, but I need to use the rank values as the x-axis on a bar chart. So, I guess I need to calculate the rank value in a column in my table. 

 

My other issue is that the value "expression" used for rankx is a measure consisting of a bunch of other measures, calculated from different rows in my main table. 

 

The measure used is a forecast that that looking at the year-to-date cost from last year compared to the hole last year cost. This percentage value is then used to calculate a forecast of this year cost, using the year-to-date cost for this year. This forecast measure is then compared to the total budget of this year, to see if the different counties are expected to keep their budget. 

 

This forecast vs budget measure is what I want so rank between the different counties. 

 

As the measure is complicated, I often get an error saying that there is a circular reference. Or I just get a bunch of 1's. 

Here is a report where I have illustrated the issue. 

 

https://1drv.ms/u/s!Akk3xPcd4O64gaop19baJ5m1yd6ENA?e=soxb3l

 

1 REPLY 1
lbendlin
Super User
Super User

but I need to use the rank values as the x-axis on a bar chart.

 

RANKX is an iterator function, it works over rows.   Putting it in a measure is always tricky.  And then trying to use that measure as another column (your x axis) is where stuff breaks the fabric of spacetime.

 

Use of RANKX in Power BI measures - SQLBI

 

You need to create a disconnected table for your expected values (  GENERATESERIES(1,10)   etc)  and then tie the measure to that table.  That will allow you to select the table column for the x axis.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors