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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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

HI @Anonymous,

 

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

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.

Anonymous
Not applicable

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 ?

Anonymous
Not applicable

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

Anonymous
Not applicable

Hello @Anonymous,

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.

Anonymous
Not applicable

 

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

DataSample.PNG

 

Anonymous
Not applicable

Hello @Anonymous,

hope you Have you got your solution. 

Anonymous
Not applicable

Thanks! @AnonymousAbove DAX expression is helped me.
Thanks! @Anonymous

Anonymous
Not applicable

HI @Anonymous,

 

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

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.