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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
hasier
Frequent Visitor

Using RANKX to order by date and more criterias

Hi,

 

I am trying to order one table by date using RankX() but taking into account that when the value is the same on column "Name" the output should be the same and that I only want to order when value at column "Task" is "PUBLISH". It's a bit difficult to explain so I show it with a table and the desired output.

 

Thank you in advance!

 

hasier_0-1665654755004.png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1665661831190.png

 

 

Rank CC =
VAR _newtable =
    FILTER ( Data, Data[Task] = "PUBLISH" )
VAR _rankcolumn =
    SUMMARIZE (
        ADDCOLUMNS (
            _newtable,
            "@rank", COUNTROWS ( FILTER ( _newtable, Data[Date] <= EARLIER ( Data[Date] ) ) )
        ),
        Data[Name],
        [@rank]
    )
RETURN
    MAXX ( FILTER ( _rankcolumn, Data[Name] = EARLIER ( Data[Name] ) ), [@rank] )


Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a meeting with me




View solution in original post

3 REPLIES 3
hasier
Frequent Visitor

Thank you very much! It works perfectly fine 😄

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1665714631979.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1665714854457.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1665661831190.png

 

 

Rank CC =
VAR _newtable =
    FILTER ( Data, Data[Task] = "PUBLISH" )
VAR _rankcolumn =
    SUMMARIZE (
        ADDCOLUMNS (
            _newtable,
            "@rank", COUNTROWS ( FILTER ( _newtable, Data[Date] <= EARLIER ( Data[Date] ) ) )
        ),
        Data[Name],
        [@rank]
    )
RETURN
    MAXX ( FILTER ( _rankcolumn, Data[Name] = EARLIER ( Data[Name] ) ), [@rank] )


Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a meeting with me




Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors