Forum Discussion

zenbabasha33's avatar
zenbabasha33
Regular Visitor
2 years ago
Solved

DAX Rank Function is not working when I choose multiple dates from the filter

hi Team,
 
I have two filter Date and Region.  when i choose one date it works we and as expected but if I do multiple date from the filter it isnot working. This is the DAX i am using below.
Rank = RANKX(
    ALLSELECTED('Royalty'),
    'Royalty'[Adjusted Gross Revenue],
    ,
    DESC,
    Skip
)
 
any kind of help would be greatly appreciated.
Thanks 
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi zenbabasha33 
    Source Data

    Rank Function

    Select any date from the slicer, the rank will adjust within itself

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi zenbabasha33 
    Source Data

    Rank Function

    Select any date from the slicer, the rank will adjust within itself

  • aduguid's avatar
    aduguid
    Icon for Memorable Member rankMemorable Member

    Try this measure. If you want to rank across all selected dates without splitting by date, you can ignore the date filter in the ranking context.

    Rank = 
    RANKX(
        ALLSELECTED('Royalty'[Region]), 
        'Royalty'[Adjusted Gross Revenue],
        ,
        DESC,
        Skip
    )

     

  • ALLSELECTED function gives you all the rows in a table, ignoring the current context filter, which might be causing the unexpected ranking result when multiple dates are selected. You can use the DAX formula below to respect the current filter context for the date.

     

    Rank = 
    RANKX(
        ALLSELECTED('Royalty'[Date], 'Royalty'[Region]), 
        'Royalty'[Adjusted Gross Revenue],
        ,
        DESC,
        Skip
    )

     


    Another approach is to use ALL on the date column specifically, rather than the entire table, which ensures that other filters like Region are still respected.