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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
gumis_rulez
Helper I
Helper I

RANKX - issue when applying slicer (incorect ranking)

I am making a simple product category ranking by product category.

 

When I use rankx function without slicer, ranking is as follows:

 

001.JPG

When I apply slicer filter f.e. on Packaged Chocalate, the ranking changes from 9 to 10:

 

002.JPG

Some rank positions after applying filter remain the same, some not.

 

The ranking function looks as follows:

Rank Test =
IF(
    HASONEVALUE(
        'Product Lookup (Updated)'[product_category]
    ),
    RANKX(
        ALL(
            'Product Lookup (Updated)'[product_category]
        ),
        [Total Sales]
    ),
    BLANK()
)
 
The exact problem above - on page 4
1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Nothing but (inevitable) floating-point inaccuracy ever since the creation of modern computer (binary notation)

ThxAlot_0-1723503287275.png

 

The solution is very straightforward,

Total Sales =
INT(
    SUMX(
        'Sales by Store',
        'Sales by Store'[quantity_sold] * 'Sales by Store'[unit_price]
    )
)

ThxAlot_1-1723503424974.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

Nothing but (inevitable) floating-point inaccuracy ever since the creation of modern computer (binary notation)

ThxAlot_0-1723503287275.png

 

The solution is very straightforward,

Total Sales =
INT(
    SUMX(
        'Sales by Store',
        'Sales by Store'[quantity_sold] * 'Sales by Store'[unit_price]
    )
)

ThxAlot_1-1723503424974.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



gmsamborn
Super User
Super User

Hi @gumis_rulez 

 

Have you tried changing ALL to ALLSELECTED?

 

Rank Test = 
    IF(
        HASONEVALUE( 'Product Lookup (Updated)'[product_category] ),
        RANKX(
            ALLSELECTED( 'Product Lookup (Updated)'[product_category] ),
            [Total Sales]
        ),
        BLANK()
    )

 

Let me know if you have any questions.



Proud to be a Super User!

daxformatter.com makes life EASIER!

When using ALLSELECTED if you select only one category, this category will have rank 1.

The goal is when you have selected packaged chocolate the rank should be calculated based on total sales of all categories and have 9 in this example.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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