Forum Discussion

ribs's avatar
ribs
Icon for Helper I rankHelper I
1 year ago
Solved

RankX- user to enter desired number to filter the RankX results of matrix is not working

  I have a matrix in Power BI and
measures for Revenue Year 1; Revenues Year 2; RankX
parameters for Revenue Year 1;  Revenue Year 2 ; TopN- for the users to choose the top count where I have a Rankif function
in the filter pane

RankIf = IF([RankX] <= 'TopN'[TopN Value]; 1; 0) set to 1 to limit the results to be displayed, which is not working because I have added customer No under the customer name to the rows pane of the matrix.



Customer20242025Dynamic Rank Compare 2024 -> 2025 or 2025->2024
A90501
B50602
C40403
D10204
E6705


Everything is working except the RankIf in filterpane so that user cannot enter manually how many top rows to display. I don't know where exactly I am going wrong. I tried to replicate the same in the attcahed below

  • Hi ribs ,
    You can try this DAX

    RankX =
    IF(
        ISINSCOPE('Customer'[Customer Name]) && NOT ISINSCOPE('Customer'[Customer No.]),
        RANKX(
            ALLSELECTED('Customer'[Customer Name]),
            [Revenue Change],
            ,
            DESC,
            DENSE
        )
    )

    This makes Rankx return blank at the Customer No. level, so it doesn’t affect or show on subcategories.


    Attached file for reference.
    Hope this helps!
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Thank You!

6 Replies

  • v-sdhruv's avatar
    v-sdhruv
    Icon for Community Support rankCommunity Support

    Hi ribs ,
    You can try this DAX

    RankX =
    IF(
        ISINSCOPE('Customer'[Customer Name]) && NOT ISINSCOPE('Customer'[Customer No.]),
        RANKX(
            ALLSELECTED('Customer'[Customer Name]),
            [Revenue Change],
            ,
            DESC,
            DENSE
        )
    )

    This makes Rankx return blank at the Customer No. level, so it doesn’t affect or show on subcategories.


    Attached file for reference.
    Hope this helps!
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Thank You!

  • ribs Try using

     

    RankX Measure: RankX = RANKX(ALL('Customer'), [Revenue Year 1], , DESC, DENSE)

     

    RankIf Measure: RankIf = IF([RankX] <= SELECTEDVALUE('TopN'[TopN Value]), 1, 0)

     

    TopN Parameter Table: TopN = GENERATESERIES(1, 10, 1)

     

    Go to the matrix visual.
    Drag the RankIf measure to the Visual Level Filters pane.
    Set the filter to show only rows where RankIf equals 1.

  • bhanu_gautam I have tried this already it is not working.In the matrix rows pane I have two columns- Customer and Customer No like the image below. Because of the subategory Customer No, the RankIf is not working. Is it possible to not to apply ranking to the subcategory? Or if at all applied, not to cosnider in RankIf()?

     

  • v-sdhruv Thank you so much! This solution is close enough to my requirement. I'll try to find a workaround as the RankX disappears when I drilldrown the visual to view one or all the customer number.

  • v-sdhruv's avatar
    v-sdhruv
    Icon for Community Support rankCommunity Support

    Hi ribs ,
    Good to know you were able to arrive at the solution.
    If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Thank You!

  • v-sdhruv's avatar
    v-sdhruv
    Icon for Community Support rankCommunity Support

    Hi @ribs ,
    Good to know you were able to arrive at the solution.
    If the response has addressed your query, please accept it as a solution so other members can easily find it.
    Thank You!