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
tomwolswijk
Helper I
Helper I

Rank date in PowerBI

Hi,

 

I'm looking for a DAX formule to rank the date kolomn. No extra filters on Client ect, just rank the date.

Every month new data is loaded in the PowerBI model. Now i want to add a Kolomn so that 1 = newest month, 2 = month before, ect. Can someone help me on this?

 

Table:

MonthClientAmount
jan-201100
feb-201122
feb-2011
mar-201140

 

Outcome:

MonthClientAmountRANK
jan-2011003
feb-2011222
feb-20112
mar-2011401
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hello @tomwolswijk ,

You can test this calculated column.

Rank = 
RANKX (
    'Table',
    RANKX ( 'Table', YEAR ( 'Table'[Date] ),, DESC, DENSE ) * 100
        + RANKX ( 'Table', MONTH ( 'Table'[Date] ),, DESC, DENSE ),
    ,
    ASC,
    DENSE
)

6.png

More details can be found here.

Best regards

Stephen Tao

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

7 REPLIES 7
Marlow
New Member

thanks

v-stephen-msft
Community Support
Community Support

Hello @tomwolswijk ,

You can test this calculated column.

Rank = 
RANKX (
    'Table',
    RANKX ( 'Table', YEAR ( 'Table'[Date] ),, DESC, DENSE ) * 100
        + RANKX ( 'Table', MONTH ( 'Table'[Date] ),, DESC, DENSE ),
    ,
    ASC,
    DENSE
)

6.png

More details can be found here.

Best regards

Stephen Tao

If this post helps,then consider Accepting it as the solution to help other members find it faster.

Thanks a lot! It worked! 

I used 'Table'[Month] instead of 'Table'[Date], because month is already a date data type. Thanks!

I tried; 

Rank =
RANKX( (
    ALLSELECTED ( Table[Month] ),
    CALCULATE ( SELECTEDVALUE ( Table[Month] ) ),
    ,
    ASC
))
 
But did not work... Can you help?

@tomwolswijk , I created a measure and then used Rank

Measure = CALCULATE(SUM('Table (2)'[Amount]) ,ALLEXCEPT('Table (2)','Table (2)'[Month]))
Measure 2 = rankx(ALL('Table (2)'[Month]),[Measure])

 

The measure you gave is to rank [Amount]. But i'm only want to give my date value a rank based on the date, without using other variables.

To make it simple:

MonthRank
01-12-20195
01-01-20204
01-02-20203
01-04-20202
01-06-20201

 

Thanks for you help

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.