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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,315
Messages
6,171,412
Members
452,399
Latest member
oranges

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