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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Seyi38
Regular Visitor

Rankx Measure Ignoring FIlters

I am trying to show Top and Bottom N categories and I have a Rankx measure for that. It works as it should when no filters are selected in the filter pane. However, when I filter by date, month, quarter, or uniqueid, the rankings are incorrect. I noticed that the filter context is ignored and it just keeps the ranking as it was before a filter was selected. I have tried different approaches but they all had different issues and gave me incorrect rankings when I selected a filter.

This is my measure to rank the Bottom categories:

 

Bottom Rank =
RANKX(
    ALL(APIOperations[operationname]),
    CALCULATE([TotalAPICalls]),
    ,
    ASC,
    DENSE
)

 

 

Any way to make it evaluate the filters before ranking?

My APIOperations Table looks like this and I have a date table connected to it.Seyi38_0-1731707614497.png

 

4 REPLIES 4
Anonymous
Not applicable

Hi @Seyi38 ,

 

Maybe you should try  ALLSELECTED instead of ALL function to create formula like below:

Bottom Rank = 
RANKX(
    ALLSELECTED(APIOperations[operationname]),
    CALCULATE([TotalAPICalls]),
    ,
    ASC,
    DENSE
)
TotalAPICalls =
CALCULATE (
    SUM ( APIOperations[No.ofAPICALLs] ),
    ALLEXCEPT ( APIOperations, APIOperations[OperationName] )
)

vkongfanfmsft_0-1731912646685.pngvkongfanfmsft_1-1731912657527.png

Best Regards,
Adamk Kong

 

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

Hi @Anonymous ,

 

Thanks for your solution. 

My bad, I actually used ALLSELECTED() and not ALL as stated above. 

 

I still encounter the same issue when trying your solution.

Bottom Rank = 
RANKX(
    ALLSELECTED(APIOperations[operationname]),
    Calculate([TotalAPICalls]),
    ,
    ASC,
    DENSE
)
TotalAPICalls = CALCULATE (
    SUM ( APIOperations[number_of_api_calls] ),
    ALLEXCEPT(Dim_Dates,Dim_Dates[Month]) //I want to abe able to apply month filters
)

Everything looks fine at first

Seyi38_0-1731953795097.png

When I select the month filter, I get blanck rows which it ranks as 1 from bottom and the actual operations for September gets a ranking from 2. 

Seyi38_1-1731953837598.png

I guess this is because it's recognizing only the Month filter so it ranks blank operations as lower than 1 instead of excluding them entirely. 
I only intend to ever filter by Month in the Dim_Dates table or uniqueID in the APIOperations table. 

lbendlin
Super User
Super User

Measure Ignoring FIlters

you mean a calculated column?

No, measure.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

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

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.