Forum Discussion

sdmikejr's avatar
sdmikejr
Helper I
10 years ago
Solved

How to use RANKX but filter out one specific customer?

I have a large customer base that are comprised of 5 customer categories. I would like to rank the top 10 customers and include all categories but one. Is there a way to do this using the Rankx expression while totaling up sales for a given time period?

  • sdmikejr Without knowing any details your Measure should look something like this... :smileyhappy:

     

    Ranking Measure =
    RANKX (
        ALL ( Table[Customer] ),
        CALCULATE ( SUM ( Table[Sales] ), Table[Category] <> "Category 5" )
    )

    You can of course use your Total Sales Measure above  (if you already have one) and then add the filter to it

    OR

    You can create a Measure to CALCULATE the Total Sales for all except Category 5 and use it in the Ranking Measure

     

    All these should work :smileyhappy:

2 Replies

  • An easier way to accomplish might be to use the Object/Page/Report level filters in PowerBI.   

     

     

     

     

     

  • Sean's avatar
    Sean
    Community Champion

    sdmikejr Without knowing any details your Measure should look something like this... :smileyhappy:

     

    Ranking Measure =
    RANKX (
        ALL ( Table[Customer] ),
        CALCULATE ( SUM ( Table[Sales] ), Table[Category] <> "Category 5" )
    )

    You can of course use your Total Sales Measure above  (if you already have one) and then add the filter to it

    OR

    You can create a Measure to CALCULATE the Total Sales for all except Category 5 and use it in the Ranking Measure

     

    All these should work :smileyhappy: