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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ribs
Helper I
Helper I

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

1 ACCEPTED SOLUTION
v-sdhruv
Community Support
Community 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.

vsdhruv_0-1747393054975.png
vsdhruv_2-1747393096005.png

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!

View solution in original post

6 REPLIES 6
v-sdhruv
Community Support
Community 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!

v-sdhruv
Community Support
Community 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!

ribs
Helper I
Helper I

@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
Community Support
Community 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.

vsdhruv_0-1747393054975.png
vsdhruv_2-1747393096005.png

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
Helper I
Helper I

@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()?

ribs_0-1747122319600.png

 

bhanu_gautam
Super User
Super User

@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.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.