editing M code

robertdseals

Active Member
Joined
May 14, 2008
Messages
337
Office Version
  1. 2010
Platform
  1. Windows
Hello all, I have a table with multiple entries for employees. I've grouped this table by employee number and I've aggregated the data by Max for day, and Max for other columns. However, I am trying to get the last entry for "company" (we have 3 companies). When I use "Max" or List.Last in the M Code, I get the last company alphabetically not chronalogically. Any thoughts on how to fix this?

Power Query:
= Table.Group(#"Removed Other Columns", {"EmployeeNumber"}, {{"MaxDay", each List.Max([ActualDate]), type nullable datetime}, {"MaxName", each List.Max([FullName]), type nullable text}, {"MaxActiveStat", each List.Max([ActiveStatus]), type nullable text}, {"MaxHireDate", each List.Max([HireDate]), type nullable datetime}, {"MaxRehireDate", each List.Max([RehireDate]), type nullable datetime}, {"MaxTermDate", each List.Max([TerminationDate]), type nullable datetime}, {"MaxCompany", each List.Last([Company]), type nullable text}, {"MaxManager", each List.Max([Manager]), type nullable text}, {"MaxDepartment", each List.Max([DeptCode]), type nullable text}, {"MaxLocation", each List.Max([WorkLocation]), type nullable text}, {"MaxDeptName", each List.Max([DepartmentName]), type nullable text}})
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
It would be helpful if you showed us some sample data (8-12 records) of what you have and then some mocked up exhibits of what you expect for results. Please use XL2BB. No pictures please.
 
Upvote 0

Forum statistics

Threads
1,223,936
Messages
6,175,508
Members
452,650
Latest member
Tinfish

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