Forum Discussion

Seyi38's avatar
Seyi38
Regular Visitor
1 year ago

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.

 

4 Replies

  • Measure Ignoring FIlters

    you mean a calculated column?

  • Anonymous's avatar
    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] )
    )
    

    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.

    • Seyi38's avatar
      Seyi38
      Regular Visitor

      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

      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. 

      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.