Forum Discussion
Most Recent Discharge Date Row Record
Please how can I get the most recent row values if I have a sample data like this.
I used the calculate and filter allexcept function but I got only the dates and not the corresponding Ids.
Table:
| patient_name | patient_Id | discharge_date | record_Id |
| Mark | 1 | 3/15/2019 | 1001 |
| John | 2 | 6/3/2020 | 1002 |
| Tom | 3 | 8/7/2020 | 1003 |
| Tom | 3 | 9/1/2020 | 1004 |
| Tom | 3 | 9/3/2020 | 1005 |
| Sarah | 4 | 2/1/2018 | 1006 |
| Kim | 5 | 7/6/2017 | 1007 |
| Mark | 1 | 4/7/2020 | 1008 |
| Tom | 3 | 11/1/2020 | 1009 |
| Steve | 6 | 3/2/2019 | 1010 |
Expected Results:
| patient_name | patient_Id | discharge_date | record_Id |
| John | 2 | 6/3/2020 | 1002 |
| Sarah | 4 | 2/1/2018 | 1006 |
| Kim | 5 | 7/6/2017 | 1007 |
| Mark | 1 | 4/7/2020 | 1008 |
| Tom | 3 | 11/1/2020 | 1009 |
| Steve | 6 | 3/2/2019 | 1010 |
Thank you so much.
Hi,
I assume you want to create a measure.
Please check the below picture and the attached pbix file.
Date record ID max date: = IF ( HASONEVALUE ( Data[patient_name] ), CALCULATE ( MAX ( Data[record_Id] ), FILTER ( Data, Data[discharge_date] = [Discharge max date:] ) ) )
3 Replies
- Jihwan_Kim
Super User
Hi,
I assume you want to create a measure.
Please check the below picture and the attached pbix file.
Date record ID max date: = IF ( HASONEVALUE ( Data[patient_name] ), CALCULATE ( MAX ( Data[record_Id] ), FILTER ( Data, Data[discharge_date] = [Discharge max date:] ) ) )- yve214
Helper III
Thank you for your help. Sorry I thought I accepted this solution. Thank you again.
- v-jianboli-msft
Community Support
Hi yve214 ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.