Calculation Issues

Calculate Monthly Roster Hours in Excel From Shift Codes

Amos GikundaAmos Gikunda Nov 12, 2026 869 views

Question details

Calculate employee monthly working hours automatically from roster shift codes that represent different hour values.

Calculate Monthly Roster Hours in Excel From Shift Codes
Product
Microsoft Excel
Device & OS
not provided
Scenario
A roster contains codes such as AM, PM, DO, and ND, and the user needs to convert them to hours and total the results by employee and month.
Observed behavior
Shift codes are text values, so they must be mapped to their corresponding working-hour values before they can be summed.
Before you start

Create a small shift-code reference table with one column for the code and one column for its hour value. Confirm that roster entries use the same spelling and do not contain unwanted spaces.

Solution 1Recommended

Use XLOOKUP to convert each shift code to working hours

Use this method when each roster cell contains one shift code and you want a calculated hours value beside it.

A lookup table lets you manage shift lengths in one place. For example, set AM and PM to 8.5, DO to 0, and ND to 10, then use a formula to return the matching value for every roster code.

1
Build a shift-code lookup table

On the same sheet or a separate sheet, enter shift codes in H2:H5 and their hours in I2:I5. For example, enter AM, DO, PM, and ND in column H, with 8.5, 0, 8.5, and 10 in column I.

2
Enter the XLOOKUP formula

If the first roster code is in B2, select the matching hours cell and enter =XLOOKUP(B2,$H$2:$H$5,$I$2:$I$5,0). The final 0 returns zero when a code is not found.

3
Fill the formula across the roster

Drag the fill handle from the formula cell across or down the hours area so every shift code returns its assigned number of hours.

4
Total the monthly hours

Select a cell at the end of an employee’s hours row and use =SUM(C2:AG2), adjusting the range to include all calculated daily-hours cells for the month.

Use XLOOKUP to convert each shift code to working hours
Update shift hours in one place: When a shift duration changes, edit its value in the lookup table and all XLOOKUP results update automatically.
Calculate roster hours with WPS Spreadsheets

Calculate Shift-Code Hours and Monthly Totals in WPS Spreadsheets

WPS Spreadsheets can convert roster codes into numeric shift hours with a lookup formula and calculate each employee’s monthly total. Create a code-to-hours table, apply XLOOKUP or VLOOKUP, and use SUM or a PivotTable for reporting.

  1. 1. Open the roster in WPS Spreadsheets: Open the employee roster workbook and identify the cells containing the daily shift codes.
  2. 2. Create the code and hours reference list: In an unused range or a separate worksheet, enter each shift code in one column and its hourly value in the next column.
  3. 3. Return hours for each shift code: In the calculated-hours column, enter =XLOOKUP(B2,$H$2:$H$5,$I$2:$I$5,0), replacing B2 and the lookup ranges with your roster locations.
  4. 4. Calculate each employee’s monthly total: Use the SUM function on the row or column of calculated hours, such as =SUM(C2:AG2).
  5. 5. Create a summary report if needed: Choose Insert > PivotTable and summarize the Calculated Hours field by employee and month.
Map AM, PM, DO, ND, and custom shift codes to the correct working hours.Use XLOOKUP, VLOOKUP, SUM, and PivotTables for roster calculations.Open and edit Microsoft Excel .xlsx and .xls roster files with compatible formulas.Use a lightweight, familiar spreadsheet interface for monthly staff scheduling.
microsoft office alternative - wps office

Frequently Asked Questions

What formula converts a roster shift code into hours?

Use XLOOKUP with a code-to-hours table. For example, if B2 contains the code and H2:I5 contains the lookup table, use =XLOOKUP(B2,$H$2:$H$5,$I$2:$I$5,0).

How do I assign zero hours to a day-off code such as DO?

Add DO to the shift-code column in the lookup table and enter 0 in its corresponding hours cell. The lookup formula will then return zero for every DO entry.

Why does my XLOOKUP formula return zero for a valid shift code?

Check that the roster code exactly matches the lookup-table code. Use TRIM on imported values if needed, such as =XLOOKUP(TRIM(B2),$H$2:$H$5,$I$2:$I$5,0).

Can I calculate totals for several employees at once?

Yes. Copy the lookup formula for all roster entries, then use SUM for each employee row or create a PivotTable with Employee in Rows and Calculated Hours in Values.

Can I use VLOOKUP instead of XLOOKUP for shift hours?

Yes. If the codes are in H2:H5 and hours are in I2:I5, use =VLOOKUP(B2,$H$2:$I$5,2,FALSE). The code column must be the first column of the selected lookup range.