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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Create new table based on status at most recent date

I have a very large dataset with multiple changes to student applications, and I would like to create a separate table which draws out only the most recent status of each student at a particular date, so that we have only 1 row of data per student rather then many.

 

The original table is laid out as follows:

StudentIdChangeDateCourseCodeStatusAcademicYear
Student101/10/2020MA1Applied2021
Student108/10/2020MA1Offered2021
Student108/10/2020MA2Accepted2022
Student204/10/2020EN1Applied2021
Student210/10/2020EN1Offered2021
Student211/10/2020EN1Accepted2021
Student302/10/2020MA2Applied2021
Student303/10/2020MA2Withdrawn2021
Student404/10/2020EN1Applied2021
Student411/10/2020EN2Offered2021
Student412/10/2020EN2Accepted2021

The ChangeDate column notes the date of changes made to any of the other fields.  Students may have more than one change per date.

 

I would like the new table to record the most recent status for each student, so the result on the 8th October 2020 for the above would be:

DateStudentIdCourseCodeStatusAcademicYear
08/10/2020Student1MA2Accepted2022
08/10/2020Student2EN1Applied2021
08/10/2020Student3MA2Withdrawn2021
08/10/2020Student4EN1Applied2021

 

and for 12th october would be:

DateStudentIdCourseCodeStatusAcademicYear
12/10/2020Student1MA2Accepted2022
12/10/2020Student2EN1Accepted2021
12/10/2020Student3MA2Withdrawn2021
12/10/2020Student4EN2Accepted2021

 

Any suggestions greatly appreciated!  Thank you.

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you want to get the student status at the most recent date based on the selection of Slicer. I think you can achieve this through a measure, you can try my steps:

  1. Create a calendar table for the Slicer:
Date = CALENDARAUTO()
  1. Create a measure:
StudentId1 =
var _selecteddate=
SELECTEDVALUE('Date'[Date])
var _rank=
RANKX(
    FILTER(ALLSELECTED('Table'),
    [StudentId]=MAX([StudentId])&&[ChangeDate]<=_selecteddate),
    CALCULATE(MAX('Table'[ChangeDate])+MAX('Table'[AcademicYear])),
    ,DESC,Dense)
var _filteredrank=
IF(MAX('Table'[ChangeDate])>_selecteddate,BLANK(),_rank)
var _studentid=
IF(_filteredrank=1,MAX('Table'[StudentId]),BLANK())
return _studentid
  1. Create a Slicer and place ‘Date’[Date] then replace the [StudentId] in the original table chart with the new measure [StudentId1], like this:

v-robertq-msft_0-1608542977872.png

 

And you can get what you want, like this:

v-robertq-msft_1-1608542977897.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you want to get the student status at the most recent date based on the selection of Slicer. I think you can achieve this through a measure, you can try my steps:

  1. Create a calendar table for the Slicer:
Date = CALENDARAUTO()
  1. Create a measure:
StudentId1 =
var _selecteddate=
SELECTEDVALUE('Date'[Date])
var _rank=
RANKX(
    FILTER(ALLSELECTED('Table'),
    [StudentId]=MAX([StudentId])&&[ChangeDate]<=_selecteddate),
    CALCULATE(MAX('Table'[ChangeDate])+MAX('Table'[AcademicYear])),
    ,DESC,Dense)
var _filteredrank=
IF(MAX('Table'[ChangeDate])>_selecteddate,BLANK(),_rank)
var _studentid=
IF(_filteredrank=1,MAX('Table'[StudentId]),BLANK())
return _studentid
  1. Create a Slicer and place ‘Date’[Date] then replace the [StudentId] in the original table chart with the new measure [StudentId1], like this:

v-robertq-msft_0-1608542977872.png

 

And you can get what you want, like this:

v-robertq-msft_1-1608542977897.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Create a new column of rank

rank = rankx(filter(Table, [student] = earlier([student])),[ChangeDate],,desc,dense)

 

Then create a new table to filter Rank =1

calculateTable(Table, filter(Table, [Rank]=1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak, I've successfully created the table based on the rank, which now shows us only the most recent status.

 

I would like this to be more dynamic if possible - I would like to be able to see the status of all students at a chosen date, as well as the final outcome, so in essence to move backwards in time and identify the exact status at a different point in the year.

 

Is this something which is possible using this method, or would I need a different approach?   I do have a "DayOfYearNumber" column on a linked Calendar table which aligns the date to a specific number, ie 01/10/2020 would be "DayOfYearNumber" = 1, as would 01/10/2019 etc, if that helps.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.