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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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