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
FrankNY007
Frequent Visitor

How to rank record by day and by same truck number and desc by created time?

Hi PowerBI Masters:

 

I have a quetion of how to rank my data in power BI, please see the sample data below:

IImage 1.png

As you can see, in the same day(I have mutiple day's data), one truck may have different records created by different time. In column D I want to created a dimension, which rank the created time by truck number by deliverydate as descding. In SQL, it should be:

  rank( ) over( TRUCKNUMBER,DELIVERYDATE order by DATECREATED desc) as Rank_Index

But I don;t know how to do it in PowerBi, I only need the lastest record for each truck on each day(which means rank=1), can anyone let me know how can I do it in data modeling view(DAX) or even query editor mode(power query)

 

Thanks

Frank

1 ACCEPTED SOLUTION

Yes, sorry typing error, I have an solution, but I am not sure if this is the best way?

 

Rank= RANKX(CALCULATETABLE(mytable,ALLEXCEPT(maytable,vehiclenumber,deliverdate)),mytable[DATECREATED],,DESC,Dense)

View solution in original post

4 REPLIES 4
FrankNY007
Frequent Visitor

anyone knows what the solution for that?

Hi

rank1 =
RANKX (
    ALLEXCEPT ( Sheet1, Sheet1[number] ),
    CALCULATE ( SELECTEDVALUE ( Sheet1[createdtime] ) ),
    ,
    DESC,
    DENSE
)

8.png

 

Best Regareds

Maggie 

@FrankNY007

 

Hi, in your sample 1007 Rank 1 (The Latest Record) Should be 22:13?




Lima - Peru

Yes, sorry typing error, I have an solution, but I am not sure if this is the best way?

 

Rank= RANKX(CALCULATETABLE(mytable,ALLEXCEPT(maytable,vehiclenumber,deliverdate)),mytable[DATECREATED],,DESC,Dense)

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.