Forum Discussion
Keep latest time value
- Anonymous7 years ago
Update to this post: The only solution I found was to write a SQL script, into the advanced options window (get data window), which selects the last date of the week and the highest value of the day.
Hi...
In power query Sort yout Date Column Descending then in Home menu click on "Queep Rows">"Keep Top Rows" will open a dialogue box in numbers of rows type 1 then OK.
Done.
Hi rafaelmpsantos,
Thanks for your reply! However there are more than one serial numbers (unit), with multiple data/time values. In fact, the time has 40+million rows.
So, I'm trying to reduce the number of rows by only keeping one data/time value per day per serial number (unit).
| receivedTime | serialNumber | |
| 1/1/2018 10:00:00 AM | abcd1234 | delete |
| 1/1/2018 11:00:00 AM | abcd1234 | delete |
| 1/1/2018 12:00:00 PM | abcd1234 | delete |
| 1/1/2018 1:00:00 PM | abcd1234 | delete |
| 1/1/2018 2:00:00 PM | abcd1234 | KEEP |
| 1/1/2018 3:00:00 PM | efgh5678 | delete |
| 1/1/2018 4:00:00 PM | efgh5678 | delete |
| 1/1/2018 5:00:00 PM | efgh5678 | delete |
| 1/1/2018 6:00:00 PM | efgh5678 | delete |
| 1/1/2018 7:00:00 PM | efgh5678 | KEEP |
| 1/1/2018 9:00:00 AM | ijkl9012 | delete |
| 1/1/2018 10:00:00 AM | ijkl9012 | delete |
| 1/1/2018 11:00:00 AM | ijkl9012 | delete |
| 1/1/2018 12:00:00 PM | ijkl9012 | delete |
| 1/1/2018 1:00:00 PM | ijkl9012 | KEEP |
| 1/1/2018 7:00:00 AM | mnop3456 | delete |
| 1/1/2018 9:00:00 AM | mnop3456 | delete |
| 1/1/2018 11:00:00 AM | mnop3456 | delete |
| 1/1/2018 1:00:00 PM | mnop3456 | delete |
| 1/1/2018 3:00:00 PM | mnop3456 | KEEP |
| … so on and so forth |
- Ashish_Mathur8 years ago
Super User
Hi,
In the Query Editor, right click on the serialNumber column and see the images below. CLick on OK to get the result (see second image below)
Hope this helps.
- Anonymous8 years agoNot applicable
Ashish_Mathur & Anonymous,
Thank you for your sugguestions ... they worked as you said, but I want to keep the last received time value from each week for each unit (serialNumber); not just last (max) time for the entire year.
So, if a unit has 70 records/ week (10 time records/ day * 7 days), I want to keep the last time recorded in the week.
I hope this makes sense, and thanks again for your suggestions!
- jthomson8 years ago
Solution Sage
It'd be a similar principle, the easiest way I can think of doing this is to create a new column using whatever logic your week runs from and to to give each entry a number for which week it belongs to, then group by a combination of the serial number and the week - I've not really used grouping that much so I'm not sure if it's got the ability to group by two fields, but if not, making another column joining your serial number and the week number then grouping by that would have a similar result
- Anonymous8 years agoNot applicable
You can try grouby feature and see if it could help.