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.
I have a column which ranks by student code and date change using the following:
StudentID | ChangeDate | AcademicYear | Rank |
Student1 | 01/10/2020 | 2019/20 | 1 |
Student1 | 02/10/2020 | 2019/20 | 2 |
Student1 | 09/10/2020 | 2019/20 | 3 |
Student2 | 02/10/2020 | 2019/20 | 1 |
Student2 | 11/10/2020 | 2019/20 | 2 |
Student2 | 12/10/2020 | 2019/20 | 3 |
Student2 | 13/10/2020 | 2020/21 | 4 |
Student3 | 07/10/2020 | 2019/20 | 1 |
Student3 | 11/10/2020 | 2019/20 | 2 |
Student3 | 16/10/2020 | 2020/21 | 3 |
Student4 | 07/10/2020 | 2019/20 | 1 |
Student4 | 08/10/2020 | 2019/20 | 2 |
What I would like is to add additional criteria in order to restart the ranking wherever there is a change of AcademicYear for each student, so the table would look as follows (changes highlighted in red):
StudentID | ChangeDate | AcademicYear | Rank | NEWRank |
Student1 | 01/10/2020 | 2019/20 | 1 | 1 |
Student1 | 02/10/2020 | 2019/20 | 2 | 2 |
Student1 | 09/10/2020 | 2019/20 | 3 | 3 |
Student2 | 02/10/2020 | 2019/20 | 1 | 1 |
Student2 | 11/10/2020 | 2019/20 | 2 | 2 |
Student2 | 12/10/2020 | 2019/20 | 3 | 3 |
Student2 | 13/10/2020 | 2020/21 | 4 | 1 |
Student3 | 07/10/2020 | 2019/20 | 1 | 1 |
Student3 | 11/10/2020 | 2019/20 | 2 | 2 |
Student3 | 16/10/2020 | 2020/21 | 3 | 1 |
Student4 | 07/10/2020 | 2019/20 | 1 | 1 |
Student4 | 08/10/2020 | 2019/20 | 2 | 2 |
Solved! Go to Solution.
Hi @Craines
Rank V2 =
RANKX (
FILTER (
Table1,
Table1[StudentID] = EARLIER ( Table1[StudentID] )
&& Table1[AcademicYear] = EARLIER ( Table1[AcademicYear] )
),
Table1[ChangeDate],
,
ASC,
DENSE
)
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
The following measure will do it @Craines I believe.
New Rank =
VAR varStudentID =
MAX( 'Table'[StudentID] )
VAR varAcademicYear =
MAX( 'Table'[AcademicYear] )
VAR Result =
RANKX(
FILTER(
ALL( 'Table' ),
'Table'[StudentID] = varStudentID
&& 'Table'[AcademicYear] = varAcademicYear
),
CALCULATE(
SELECTEDVALUE( 'Table'[ChangeDate] )
),
,
ASC,
DENSE
)
RETURN
Result
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi @Craines
Rank V2 =
RANKX (
FILTER (
Table1,
Table1[StudentID] = EARLIER ( Table1[StudentID] )
&& Table1[AcademicYear] = EARLIER ( Table1[AcademicYear] )
),
Table1[ChangeDate],
,
ASC,
DENSE
)
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
@Craines try this
Rank = RANKX( FILTER( 'Rank', 'Rank'[StudentID] = EARLIER( 'Rank'[StudentID] ) && 'Rank'[AcademicYear] = EARLIER('Rank'[AcademicYear])), 'Rank'[ChangeDate] , , ASC, DENSE)
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |