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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.