Power Query 2016: return the latest date in a subset

SOQLee

Board Regular
Joined
Mar 18, 2015
Messages
58
Office Version
  1. 365
Platform
  1. Windows
I have tracking data that contains many dates for the same person. How can records be cleaned up so that it shows only the latest date for each person. Here is an example of the data:

DatePersonnelSold
2017-11-11Bill87
2017-11-11Susan73
2017-11-11Susan-5
2017-11-09Alexis26
2017-11-12Alexis0
2017-11-12Alexis75
2017-11-08Kate19
2017-11-07Bill33
2017-11-07Bill-15
2017-11-13Susan25
2017-11-14Kate82
2017-11-13Kate-7

<tbody>
</tbody>
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
1) I've assumed your data source is an Excel table in the current workbook called "Tracking".
2) I've assumed your columns are called "Date", "Personnel" and "Sold", as shown in your example.

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Tracking"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Personnel"}, {{"All Rows", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Last Record", each Table.Max([All Rows], "Date")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Last Date", each Record.Field([Last Record], "Date")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Last Sales", each Record.Field([Last Record], "Sold")),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom2",{"Personnel", "Last Date", "Last Sales"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"Personnel", type text}, {"Last Date", type date}, {"Last Sales", type number}})
in
    #"Changed Type"
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top