cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.

1 ACCEPTED SOLUTION
Super User

Hi,

Please check the below picture and the attached pbix file.

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

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.

3 REPLIES 3
Frequent Visitor

Thank you very much! It works perfectly fine 😄

Community Champion

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

 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!
Super User

Hi,

Please check the below picture and the attached pbix file.

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

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.

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

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

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors