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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

RANKX WITH A DATE COLUMN

Hi everyone 🙂

 

Hope you guys can help me explain how the function really works.

I have a draft dataset as below. And I need to rank the date (1st rank for the latest date) both by shop and by status (this means the rank will reset after we change to other subsets)

photo1.png

 

I used the dax function:

RANK2 =
RANKX(ALLEXCEPT(Sheet1,Sheet1[SHOPCODE],Sheet1[STATUS]),CALCULATE(SELECTEDVALUE(Sheet1[DATE])))
 
Honestly, I found the solution by luck, but I really want to understand how the context works. There are some questions that I am unclear about the answer:
  • How the 'selected value' function works in this context. If i don't use this function, is there any alternative way? I believe that if the column "date" is replaced by another column with number (ex: sales amount) then I can use calculate(sum(Sheet1[Sales Amount]), which is understandable to me in this case.
  • If I remove calculate function, the whole function will become: 

    RANK2 =
    RANKX(ALLEXCEPT(Sheet1,Sheet1[SHOPCODE],Sheet1[STATUS]),SELECTEDVALUE(Sheet1[DATE]))
    .Then the rank results return 1 for all rows and I don't really get it. How does the calculate function help in this case?
 I am just a newbie to DAX and hope you guys can help give me a solid explanation. Much appreciated for your help 🙂
 

 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors