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.
Hi everyone,
I'm trying to get the most recent and second most recent values in my table. I've looked up several examples on here, but the my data doesn't have a date value to check the most recent value with, although I can use a TestID to check the chronological order of the data with (eg: lower TestID means this was done earlier).
Any suggestion on how I can go about with this?
StudentID | TestCode | TestID | Rating |
Student0061 | Test00002 | 299470 | 92.54 |
Student0061 | Test00002 | 318610 | 38.15 |
Student0061 | Test00003 | 318610 | 54 |
Student0061 | Test00006 | 318610 | 43.91 |
Student0062 | Test00003 | 310912 | 89 |
Student0062 | Test00003 | 324512 | 89 |
Student0063 | Test00011 | 301876 | 46.63 |
Student0063 | Test00011 | 311438 | 100 |
Student0064 | Test00003 | 296873 | 96 |
Student0065 | Test00005 | 311371 | 96.82 |
Student0066 | Test00003 | 307311 | 75 |
Student0066 | Test00003 | 308344 | 77 |
Student0066 | Test00003 | 321068 | 74 |
StudentID | TestCode | Most Recent | 2nd Most Recent |
Student0061 | Test00002 | 38.15 | 92.54 |
Student0061 | Test00003 | 54 | |
Student0061 | Test00006 | 43.91 | |
Student0062 | Test00003 | 89 | 89 |
Student0063 | Test00011 | 100 | 46.63 |
Student0064 | Test00003 | 96 | |
Student0065 | Test00005 | 96.82 | |
Student0066 | Test00003 | 74 | 77 |
Solved! Go to Solution.
@olimilo solution attached, look at table2 and page 3 in attached.
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.
@olimilo here are two measures which would work
Most Recent = CALCULATE( MAX( Table2[Rating] ), FILTER( ALLEXCEPT( Table2, Table2[StudentID], Table2[TestCode] ), Table2[Index] = MAX( Table2[Index] ) ) ) Most Recent 2 = CALCULATE( MAX( Table2[Rating] ), FILTER( ALLEXCEPT( Table2, Table2[StudentID], Table2[TestCode] ), Table2[Index]= MAX( Table2[Index] ) - 1 ) )
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.
Hi @parry2k
Thank you, but unfortunately both measures didn't work for me. Also, using an Index - 1 filter for the 2nd most recent took data from other students and other test codes.
@olimilo I think I missed to point out that you need to add index field using query editor.
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.
@olimilo solution attached, look at table2 and page 3 in attached.
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 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |