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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Summarize and Rankx issues

 

Scenario:

I have a poll data with lots and lots of columns.

 

I want to display a pie chart with top 5 (out of aprox 300) items by count of mentions for one specifc column, the rest has to be grouped in an "Others" bucket:

Pie.PNG

So what I did is to create a new table on Desktop:

 

TableTop5 = SUMMARIZE(Vox,Vox[Item],"Quantity",COUNTA(Vox[Item]))

 

Then added a column to the table TableTop5:

 

Top = IF(RANKX(ALLSELECTED(TableTop5),TableTop5[Quantity],,DESC,Skip)<=5,TableTop5[Item],"Others")

 

I am using slicers to filter key topics of the polls (Year, Region, City, etc.)

 

With the slicers set in "All", the results are perfect.

 

Now, the issues:

 

If I apply any filter (filters to table Vox) the total count in table TableTop5 is wrong, the count on the top 5 elements does not move.

 

Rank is always the same, it does not recalculate with any filter applied, the Rank is calculated and fixed for the 100% of the data. No matter what filter I do Rankx results is always the same. Even if I use a filter to select on the Item column. If I remove (filter out) item ranked in #2, the result is that now I have a top 4 and Others.

 

Thank you in advance for your ideas and input to resolve this issue.

 

With no

4 REPLIES 4
BetterCallFrank
Resolver IV
Resolver IV

Hi,

you could just try to move the RANKX calculation from a calc. column to a calc measure in the same table.

This will be re-evaluated every time you change a filter/slicer and will therefore always give you the correct results.

Does this help?

Anonymous
Not applicable

Hi, seems to be the way to go, but I am having trouble converting this column formula in order to work as a measure:

 

Top = IF(RANKX(ALLSELECTED(TableTop5),TableTop5[Quantity],,DESC,Skip)<=5,TableTop5[Item],"Others")

 

 Thank you in advance for helping me on this one.

 

Luis, can you upload a PBIX file somewhere?

 

As for a generic solution the measure could look something like this:

 

Rank = 
VAR CurrQty = CALCULATE( SUMX( _Measures, _Measures[Quantity] ) )
RETURN
COUNTROWS( 
  FILTER( 
    ALL( DimProduct ), 
    CALCULATE( SUMX( _Measures, _Measures[Quantity] ) ) > CurrQty 
  )
) + 1
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous.

When you rank the TableTop5[Quantity], it will calculated for all rows in resource data. The rank is same when you select different values in different slicer. You want to rank accoring to slicer, right? Based on the description, I am not able to reproduce the scenario, could you please share sample data for further analysis?

Best Regards,
Angelia


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.