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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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.LeanAndPractise(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.LeanAndPractise(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.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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