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
Anonymous
Not applicable

Rank

Hello everybody!

 

I hav a issue in DAX and can't resolve.

It's a simple Ranking that reset it's count for every "SET", "Bloq" and "Name", based in the "Date" Column.

 

Normaly we use a agregate column, like a sum of values, to use as Rank Ruler, but i need use a date field.

The Rank Resets for every Other column change.

 

My need is to see where is the order of actions taked by time.

Colored in red is the desired result.

 

NameBloqSetDateRank Needed
Peter Paul1Run17/05/20181
Peter Paul1Bike21/05/20182
Peter Paul1Bike25/05/20183
Peter Paul1Bike06/07/20184
Peter Paul2Run12/04/20181
Peter Paul2Bike21/05/20182
Peter Paul2Bike06/07/20183

 

Thax for the help.

 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may get it with RANKX Function.For example:

Calculated colum

Column = 
RANKX (
    FILTER (
        Table1,
        Table1[Name] = EARLIER ( Table1[Name] )
            && Table1[Bloq] = EARLIER ( Table1[Bloq] )
    ),
    Table1[Date],
    ,
    ASC
)

1.png

Or a measure:

Measure = 
RANKX (
    FILTER (
        ALL ( Table1 ),
        Table1[Name] = MAX ( Table1[Name] )
            && Table1[Bloq] = MAX ( Table1[Bloq] )
    ),
    CALCULATE ( MAX ( Table1[Date] ) ),
    ,
    ASC
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may get it with RANKX Function.For example:

Calculated colum

Column = 
RANKX (
    FILTER (
        Table1,
        Table1[Name] = EARLIER ( Table1[Name] )
            && Table1[Bloq] = EARLIER ( Table1[Bloq] )
    ),
    Table1[Date],
    ,
    ASC
)

1.png

Or a measure:

Measure = 
RANKX (
    FILTER (
        ALL ( Table1 ),
        Table1[Name] = MAX ( Table1[Name] )
            && Table1[Bloq] = MAX ( Table1[Bloq] )
    ),
    CALCULATE ( MAX ( Table1[Date] ) ),
    ,
    ASC
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-cherch-msft ,

 

Thanks for the reply!

Works like a charm!

Anonymous
Not applicable

Can do this much easier in Power Query with GroupBy and then add in index column. But why is this two, shoud it be one since Set is different?

 

NameBloqSetDateRank Needed
Peter Paul1Run17/05/20181
Peter Paul1Bike21/05/20182
Anonymous
Not applicable

@Anonymous , Thanks for the reply.

I Know is easier to make this in Power Query, but i really need to make this in DAX.

 

For your questions about the SET, its because I need to know the date of every name and Bloq, but not the Set and rank then.

 

All this to know if the Person do the SET in the order I predicted.

Anonymous
Not applicable

No problem, this will work as a calculated column:

Calc Column Rank = 
Var CurrentBloq= Table3[Bloq]
Var CurrentName = Table3[Name]
Var CurrentDate = Table3[Date]
Return

CALCULATE(
    COUNTROWS( Table3 ),
    FILTER( 
        ALL( Table3 ),
        CurrentBloq = Table3[Bloq]
        && CurrentName = Table3[Name]
        && CurrentDate >= Table3[Date]
    )
)

Cal Column Rank, CountRows, Earlier.png

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.