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

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.

Reply
Anonymous
Not applicable

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:

 

VehicleStatusTimeLocation
Vehicle ASTART14/07/2020 14:44N26°08.853 E049°53.233
Vehicle ASTOP14/07/2020 13:59N26°08.050 E049°52.450
Vehicle ASTART14/07/2020 13:29N26°14.482 E049°59.775
Vehicle ASTOP14/07/2020 11:59N26°15.993 E050°01.205
Vehicle ASTART14/07/2020 11:43N26°10.472 E049°55.988
Vehicle BSTOP14/07/2020 19:29N24°07.455 E049°06.635
Vehicle BSTART14/07/2020 19:14N24°12.902 E049°05.660
Vehicle BSTOP14/07/2020 18:29N24°42.993 E049°05.212
Vehicle BSTART14/07/2020 17:59N24°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!

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Add this in your vehicles table:

Lastest Time = CALCULATE(MAX('Table'[Time]),'Table'[Vehicle]=EARLIER(VEHICLES[Vehicle]))

________________________

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 🙂

YouTube, LinkedIn
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

8 REPLIES 8
richbenmintz
Solution Sage
Solution Sage

Hi @Anonymous,

 

Wow @parry2k and @Fowmy  are fast, 

 

Another approach would be to derive the rows you are looking for during data ingestion. see the linked .pbix.

essentially ranks the data in power query then creates a filtered table  where the rank = 1

 

sample.pbix 

 

richbenmintz_0-1596033243206.png

 



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not 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 😕

Fowmy
Super User
Super User

@Anonymous 

Add this in your vehicles table:

Lastest Time = CALCULATE(MAX('Table'[Time]),'Table'[Vehicle]=EARLIER(VEHICLES[Vehicle]))

________________________

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 🙂

YouTube, LinkedIn
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Sorry, thought that was all I needed - how can I edit that to pull through the other columns (status, location etc)?

@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 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thank you! I think this is exactly what we need 👍

@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.



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.

Anonymous
Not applicable

Thank you! Thought it was an easy thing, I was just missing EARLIER.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors