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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

RANKX has behaved every way but the right way

Hey community, could really use your help with this.

My database has rows of transactions. I am trying to rank them based on their average margin in a table visual, by state.

Because I am pulling from different data sources for the same visual, I created a State dimension table to connect my transactions with another fact table (that gives me other data I need by state). I have been unsuccessful using the State field from both my State table and my transaction table.

The following equations have not worked:

Rank Margin % = RANKX(ALL(Table[State]),CALCULATE([Margin % Measure]))    - Returns 1's and 2's, no discernible pattern.

Rank Margin % = RANKX(ALLSELECTED(Table[State]),CALCULATE([Margin % Measure]))    - Returns 1's and 2's

Rank Margin % = RANKX(ALLSELECTED(Table[State]),CALCULATE([Margin % Measure]),,ASC,Dense) - Returns 2's and 3's

Rank Margin % = RANKX(ALLSELECTED(Table[State]),CALCULATE([Margin % Measure]),,ASC,Skip) - Returns 43's. I think there are 44 states in my database, with only 25 in the visual.

The measure I am ranking on was initially just an average of the column, then the measure by itself, and now the CALCULATE(Measure) also doesn't work.

Please let me know if you can help! Appreciate it.

Thanks
2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Can you provide simple EXCEL data or simple PBIX files for testing? What kind of results do you expect? Is it possible to provide pictures for reference. Looking forward to more details you can provide, thank you.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Does this work?

Rank Margin % = RANKX(ALLSELECTED(Table[State]),[Margin % Measure])

If not, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors