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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ivan_abboud
Frequent Visitor

Dynamic RANKX Based on Date Slicer

Hello Community

 

I have an order history table that shows the order per customer and the corresponding date of order

I want to create a rank for each customer order to know which was the first order of that customer, second, etc..

I've managed to do that using the following Dax formula

RankPerCustomer =
RANKX(
    FILTER(
        ALL('receipts'),
        'receipts'[customer_id] = EARLIER('receipts'[customer_id])
    ),
    'receipts'[date_created_local],
    ,
    ASC,
    Dense
)
and it's working fine as shown in the following
 
ivan_abboud_2-1702118144853.png

 

The problem is that I have a date slicer filter and I want these ranks to be recalculated based on the filtered data

whenever I'm trying to change the date range, the ranks will never change, and it will be calculated based on the whole data, I want to recalculate the rank based on the specified date range

for example in the following to show 1 and 2 for "ivan" as per the specified date this was his first and second order

ivan_abboud_3-1702118169331.png

 

I tried multiple solutions but nothing seemed to work
I appreciate your help guys,

Thanks in advance

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @ivan_abboud 
Please refer to the linked pbix and recreate a logic , for your data.

Note, that you have to use the "Dim date" table.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

6 REPLIES 6
bhanu_gautam
Super User
Super User

@Ritaf1983 , it works thanks for your effort




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Ritaf1983
Super User
Super User

Hi @ivan_abboud 
Please refer to the linked pbix and recreate a logic , for your data.

Note, that you have to use the "Dim date" table.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 
Thanks for the solution, but, actually this is not what I'm looking for

 

I need to rank orders based on their date, per customer
so for each customer, I want to see his first purchase, second, and so on... and I managed to do this using a calculated column and dax as I explained previously. 
My problem now is that I want to get this data filtered by date and recalculate the ranks based on that

Hi,

If you still need help, then share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 
please check the pbix file, it's just a simplified version of the original data
Dynamic Rank with Slicer 

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1702305103639.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors