Forum Discussion
Identify the most recent data
Hi,
I have a data dump from a vehicle tracking system, that records the time, location etc each time a vehicle's ignition is switched on or off. A simplified view is as below:
| Vehicle | Status | Time | Location |
| Vehicle A | START | 14/07/2020 14:44 | N26°08.853 E049°53.233 |
| Vehicle A | STOP | 14/07/2020 13:59 | N26°08.050 E049°52.450 |
| Vehicle A | START | 14/07/2020 13:29 | N26°14.482 E049°59.775 |
| Vehicle A | STOP | 14/07/2020 11:59 | N26°15.993 E050°01.205 |
| Vehicle A | START | 14/07/2020 11:43 | N26°10.472 E049°55.988 |
| Vehicle B | STOP | 14/07/2020 19:29 | N24°07.455 E049°06.635 |
| Vehicle B | START | 14/07/2020 19:14 | N24°12.902 E049°05.660 |
| Vehicle B | STOP | 14/07/2020 18:29 | N24°42.993 E049°05.212 |
| Vehicle B | START | 14/07/2020 17:59 | N24°43.668 E049°05.543 |
I have then created a second table which just lists the vehicles. How can I populate that table with only the most recent records from the data dump (the blue lines above)?
Thanks!
Anonymous
Add this in your vehicles table:
8 Replies
- FowmySuper User
Anonymous
Add this in your vehicles table:- AnonymousNot applicable
Thank you! Thought it was an easy thing, I was just missing EARLIER.
- parry2kSuper User
Anonymous add a measure using following expression:
Recent Date = CALCULATE ( MAX ( Table[Date] ), ALLEXCEPT ( Table, Table[Vehicle] ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos 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.⚡
- AnonymousNot applicable
Sorry, thought that was all I needed - how can I edit that to pull through the other columns (status, location etc)?
- FowmySuper User
Anonymous
If you need a new table that brings only the records for each vehicle with its latest date, add this code by clicking on the New Table under Home tab:Latest Dates Table= FILTER( 'Table', VAR _MAX = CALCULATE( MAX('Table'[Time]), ALLEXCEPT('Table',VEHICLES[Vehicle]) ) RETURN 'Table'[Time] = _MAX )________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
- richbenmintzResident Rockstar
- AnonymousNot applicable
I like the look of your solution, saves the need for the second table, but I'm not sure how you got to the stage in your screenshot? I have very limited knowledge of the query editor 😕