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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Tejesh_Gour
Helper I
Helper I

Rank based on three fields

I tried to write DAX expression in TOM Model to get the rank based on three categories but didn't got solution.

Ex: There are 2 schools and each schools have different year and each year have date.Table contains other columns as well but I need rank on three columns.

Please share any idea.

1 ACCEPTED SOLUTION

HI @Tejesh_Gour,

 

According to your description and snapshot, you want to rank datevalue based on current 'schoolid' and 'yearid' category, right?

If this is a case, you can try to use following calculated column formula:

RANK =
COUNTROWS (
    FILTER (
        ALL ( Table ),
        Table[SchoolId] = EARLIER ( Table[SchoolId] )
            && [YearId] = EARLIER ( Table[YearId] )
            && Table[DateValue] < EARLIER ( Table[DateValue] )
    )
)
    + 1

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

pls share sample data structure of your database , mainly that three column should would availble in data structure.

Thanks.

Data.PNG

 

 

Anonymous
Not applicable

Hello,
pls tell me the field name on which you want to rank.

Ex. Strength of student in schools, Achievement of schools etc, 

so on what basis you want a rank ?

Thanks! I have highlighted in screenshot.
SchoolId, YearID, and DateValue

Anonymous
Not applicable

Hello @Tejesh_Gour,

pls send me the output you want for your data pls just type it in excel and send me that, so i can understand what you exactly want.

 

I'm looking for RANK field which is in attached screenshot.

DataSample.PNG

 

Anonymous
Not applicable

Hello @Tejesh_Gour,

hope you Have you got your solution. 

Thanks! @AnonymousAbove DAX expression is helped me.
Thanks! @v-shex-msft

HI @Tejesh_Gour,

 

According to your description and snapshot, you want to rank datevalue based on current 'schoolid' and 'yearid' category, right?

If this is a case, you can try to use following calculated column formula:

RANK =
COUNTROWS (
    FILTER (
        ALL ( Table ),
        Table[SchoolId] = EARLIER ( Table[SchoolId] )
            && [YearId] = EARLIER ( Table[YearId] )
            && Table[DateValue] < EARLIER ( Table[DateValue] )
    )
)
    + 1

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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