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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Rankx is not working properly when filter is applied

Dear Power Bi experts,

 

I am trying to put row numeration on my table visualization and to accomplish this task a came up with RANKX(I would be happy if there are simple ways to put just row numeration to the table, because RANKX is too complex). However, my Rankx is working fine if there is any filter until I apply any filter from the Filter section. Below I attached 2 versions of my table(№ column is important). The first table shows ranking correctly, but when I applied the Top 30 filters by import value, it is showing my not proper ranking order. What is the problem?

 

My measure is 

№ = VAR ProductRank = RANKX(ALLSELECTED(stat_kgd_2011_2020_monthly[2 digit], stat_kgd_2011_2020_monthly[Group]), CALCULATE(SUM(stat_kgd_2011_2020_monthly[Import value])),,DESC) RETURN ProductRank
Безымянныйs.png
 
 
2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@Anonymous 

I am not sure about your model, try the following measure, if you could share a sample file I can check on it.

№ = VAR ProductRank = 
    RANKX(
        ALLSELECTED(stat_kgd_2011_2020_monthly), CALCULATE(SUM(stat_kgd_2011_2020_monthly[Import value])),,DESC) 
    RETURN 
    ProductRank

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Hi @Anonymous ,

 

Just try the following measure:

 

 

№ =
VAR A =
    CALCULATETABLE (
        ALLSELECTED (
            stat_kgd_2011_2020_monthly[2 digit],
            stat_kgd_2011_2020_monthly[Group]
        ),
        ALLSELECTED ( stat_kgd_2011_2020_monthly )
    )
RETURN
    RANKX (
        A,
        CALCULATE ( SUM ( stat_kgd_2011_2020_monthly[Import value] ) ),
        ,
        DESC
    )

 

If it doesn't work, please show us some  sample data by onedrive for business. Thanks for your understanding and support.

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , how are you using top N filter.

Top N visual level filter ?

or like

Top 10 City Rank = CALCULATE([Sales],TOPN(10,all(Geography[City]),[Sales],DESC),VALUES(Geography[City Id]))

 

or

sumx(filter(stat_kgd_2011_2020_monthly,[№ ]<=30),stat_kgd_2011_2020_monthly[Import value])

Anonymous
Not applicable

@amitchandak I am filtering from the right side table in the power Bi interface, so a I am not creating any measure for TopN

Hi @Anonymous ,

 

Just try the following measure:

 

 

№ =
VAR A =
    CALCULATETABLE (
        ALLSELECTED (
            stat_kgd_2011_2020_monthly[2 digit],
            stat_kgd_2011_2020_monthly[Group]
        ),
        ALLSELECTED ( stat_kgd_2011_2020_monthly )
    )
RETURN
    RANKX (
        A,
        CALCULATE ( SUM ( stat_kgd_2011_2020_monthly[Import value] ) ),
        ,
        DESC
    )

 

If it doesn't work, please show us some  sample data by onedrive for business. Thanks for your understanding and support.

 

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

 

Best Regards,

Dedmon Dai

Fowmy
Super User
Super User

@Anonymous 

I am not sure about your model, try the following measure, if you could share a sample file I can check on it.

№ = VAR ProductRank = 
    RANKX(
        ALLSELECTED(stat_kgd_2011_2020_monthly), CALCULATE(SUM(stat_kgd_2011_2020_monthly[Import value])),,DESC) 
    RETURN 
    ProductRank

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.