Excel Formula to Assign Option Values and Calculate Employee Totals
Question details
The user needs to assign specific numerical values to text codes (e.g., CO=1, LA=0.5, EO=0.5) to calculate daily employee totals, which will later be fed into a pivot table.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating employee attendance or specific operational totals where text strings correspond to numerical values across daily log entries.
- Observed behavior
- The user needs a reliable formula to automatically translate text options into numbers and sum them across rows for each employee.
Ensure you know which daily entry columns contain your data (e.g., B2:H2). If your version of Excel does not support modern dynamic array functions like XLOOKUP, you can use the COUNTIF alternative provided.
Calculate Totals Using SUM and XLOOKUP
Create a mapping table for your custom values and use a combined SUM and XLOOKUP formula to calculate employee totals efficiently.
This method is highly scalable. By keeping your assigned values in a dedicated lookup table, you can easily change the values later without needing to rewrite your formulas.
In an empty area of your sheet (e.g., K2:L4), list your text codes (CO, LA, EO) in one column and their corresponding numerical values (1, 0.5, 0.5) in the adjacent column.
Select the cell where you want the employee's total to appear. Type the formula =SUM(XLOOKUP(B2:H2,$K$2:$K$4,$L$2:$L$4,0)), replacing B2:H2 with your actual daily entry range.
Press Enter to calculate the first total. Click the bottom-right corner of the target cell and drag the fill handle down to apply this calculation to all employees.

Calculate Totals Using COUNTIF (For Older Excel Versions)
If your version of Excel does not support XLOOKUP, you can calculate the totals by counting the occurrences of each text code and multiplying them by their respective values.
Seamlessly Calculate Data with WPS Spreadsheet
WPS Spreadsheet offers full support for advanced array formulas like XLOOKUP and SUM, allowing you to easily assign values and calculate employee totals. It is lightweight and highly compatible with Microsoft Excel.
- 1. Download WPS Office: Install WPS Office Free from the official website and open WPS Spreadsheet.
- 2. Open your worksheet: Load your employee tracking document into the software.
- 3. Apply the calculation formula: Enter the exact same =SUM(XLOOKUP(...)) or =COUNTIF(...) formula, as WPS Spreadsheet perfectly supports all Excel functions.

Frequently Asked Questions
Why is my formula returning a #N/A error?
A #N/A error usually means a text entry in your daily log doesn't match the lookup table. Ensure the 'if_not_found' argument in your XLOOKUP formula is set to 0, and check for hidden spaces in your data cells.
Can I link these totals directly to a Pivot Table?
Yes. Once you calculate the totals in your source data rows, you can insert a Pivot Table and select this new total column as one of your value fields to easily summarize monthly data by employee.
Is there a simpler way if I only have two or three codes?
If you only have a few text codes, using the COUNTIF formula (e.g., =COUNTIF(Range, "CO")*1 + COUNTIF(Range, "LA")*0.5) is simpler as it does not require setting up a separate mapping table on your sheet.




