Forum Discussion
Sorting
I’m trying to sort these columns by name but I need the lines for each employee to stay with their associated employee. For example Caleb smith is employee number 1 and the three lines above him are associated with him so if I were to sort alphabetically it throws it off into a weird order. Any help to get this sorted would be much appreciated!
In a custom sort, you could sort on employee number first, then on material (or another column).
That will keep the rows for each employee together.
- LeeWhitt23Copper ContributorHowever this will not alphabetize the employees right?
No, the layout is not suitable for that.
- djclementsBronze Contributor
LeeWhitt23 How about adding a calculated column to the table for the employee name? With the help of a separate employee lookup table, you could use the XLOOKUP function to accomplish this. For example:
=XLOOKUP([@[EMP'#/LOCK'#]], tblEmployees[ID], tblEmployees[NAME])
Then sort the table by the calculated "NAME" column from A to Z:
Note: if the XLOOKUP function is not available in your version of Excel, use the INDEX / MATCH equivalent:
=INDEX(tblEmployees[NAME], MATCH([@[EMP'#/LOCK'#]], tblEmployees[ID], 0))
Please see the attached sample workbook...