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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
lemaribdb
Helper II
Helper II

RANKX fails with more rows

Hi guys! I have simple RANKX DAX:

 

1. Amount RANKX =
RANKX(
    ALLSELECTED('DIM_CUSTOMER'[Name]),
     '1. X_Measures[Amount],,
     DESC,
     Dense)

 

 

It all works,  I put Customer Name as Row, this measure together with Amount in values, there is a ranking visible, all works nicely.
But as soon as I add another row from different table under the Customer Name (for example Contract Number), it immediatly fails saying that it exceeded all available resources.

I assume that this calculation tries to rank further on the next row too? Can I somehow change this measure to behave correctly?
When I do it the default way (Using the built in filters, putting customer name then selecting TopN option and Amount as data), it works perfectly no matter how many drilldown are there. But the TopN is fixed there, thus my workaround.

4 REPLIES 4
lemaribdb
Helper II
Helper II

I've tried using IF(ISINSCOPE()) but seems it only works for rows "on top" of the one we do ranking on, the ones below still get some ranks, thus I imagine the resource issue. Still looking for solution.

123abc
Community Champion
Community Champion

Here are a few approaches you can try to address this issue:

 

  1. Optimize the DAX expression: Ensure that your DAX expression is as optimized as possible. Sometimes, small changes in the DAX expression can significantly improve performance. For example, you could check if there are any unnecessary filters or columns being included in the calculation.

  2. Use context transition: You can try using context transition functions like CALCULATE or FILTER to evaluate the RANKX expression within a smaller context, which might improve performance. For example, you could try something like:

    DAX
     
    Amount RANKX = RANKX( FILTER(ALLSELECTED('DIM_CUSTOMER'[Name]), HASONEVALUE('DIM_CUSTOMER'[Name])), '1. X_Measures[Amount], DESC, Dense )

    This limits the calculation of RANKX to only the rows where 'DIM_CUSTOMER'[Name] has a single value.

lbendlin
Super User
Super User

Move the measure outside the RANKX so that it will be computed only once.

This measure is already computed outside.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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