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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How do I use RANK() to rank date

Hi, 

 

I am new to PowerBI!

 

What I have is the EQP_ID & FCST_TIME, and I would like to add a column  called "Rank' to display the FCST_OUT_TIME ranking by Measure Function

The earliest FCST_OUT_TIME will be ranked as 1, 2,... and so on 

Time includes year, month, day, hour and minute

The total number of of equippment is 85 

While some equippment is not being used, the time will be null(and rank 0)

HCTSAOE_0-1723438849639.png

How do I solve it, thanks!

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @Anonymous 

 

please check if this accomodate your need.

Irwan_0-1723440998396.pngIrwan_1-1723441055825.png

 

create new calculated column with following DAX:

Rank =
var _Rank =
RANKX(
    FILTER(
        'Table',
        'Table'[FCST_OUT_TIME]
    ),
    'Table'[FCST_OUT_TIME],
    ,ASC
)
Return
IF(
    ISBLANK('Table'[FCST_OUT_TIME]),
    0,
    _Rank
)

 

Hope this will help you.

Thank you.

View solution in original post

8 REPLIES 8
Irwan
Super User
Super User

hello @Anonymous 

 

please check if this accomodate your need.

Irwan_0-1723440998396.pngIrwan_1-1723441055825.png

 

create new calculated column with following DAX:

Rank =
var _Rank =
RANKX(
    FILTER(
        'Table',
        'Table'[FCST_OUT_TIME]
    ),
    'Table'[FCST_OUT_TIME],
    ,ASC
)
Return
IF(
    ISBLANK('Table'[FCST_OUT_TIME]),
    0,
    _Rank
)

 

Hope this will help you.

Thank you.

Anonymous
Not applicable

HCTSAOE_1-1723444400178.png

@Irwan The error is as above. How can I fix it? Thank you!

hello @Anonymous 

 

it couldnt find the column probably because the column name that i wrote is different from your column name.

 

otherwise please check whether you use measure or calculated column.

@Jihwan_Kim 's solution is using measure while my solution is calculated column.

That systax error is @Jihwan_Kim 's solution.

Irwan_0-1723507386902.png

 

you are free to use either of them depend on your needs but please do take a note that writing DAX in calculated column and measure is slightly different.

 

Hope this will help you.

Thank you.

Anonymous
Not applicable

Hi, thanks for explanation. It works! 

hello @Anonymous 

 

glad to be a help.

 

Thank you.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_1-1723441163613.png

 

 

RANK function (DAX) - DAX | Microsoft Learn

 

 

Rank measure: =
IF (
    HASONEVALUE ( data[eqp_id] ),
    RANK (
        SKIP,
        SUMMARIZE (
            FILTER ( ALL ( data ), data[fcst_out_time] <> BLANK () ),
            data[eqp_id],
            data[fcst_out_time]
        ),
        ORDERBY ( data[fcst_out_time], ASC )
    ) + 0
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

HCTSAOE_0-1723444269606.png

@Jihwan_Kim  It seems that I can't use the function RANK() on my laptop. How can I fix, thank you!

 

Anonymous
Not applicable

And there's also another error message

HCTSAOE_0-1723444606336.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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