Formula Errors

How to Return an Employee First Name or Surname Based on Conditions in Excel

Tauseeq MagsiTauseeq Magsi Oct 23, 2026 870 views

Question details

The user needs an Excel formula to output an employee's first name if they are currently employed and their salary increase is under 26%. Otherwise, the formula should output their surname.

How to Conditionally Return an Employee's First Name or Surname in Excel
Product
Excel
Device & OS
not provided
Scenario
Extracting specific parts of a name string (first name vs. surname) based on multiple logical conditions, such as employment status and salary increase percentage.
Observed behavior
The goal is to automatically display either the first name or the surname in a target cell depending on whether the employee meets the specified date and salary criteria.
Before you start

Ensure your employee name data is formatted consistently with a comma separator (e.g., 'FirstName, Surname') and that your date and salary columns contain valid numeric or date values rather than text.

Solution 1Recommended

Use a Nested Formula with IF, AND, LEFT, and RIGHT Functions

This method combines logical tests with text-extraction functions to dynamically display the correct part of the name based on the salary and date conditions.

To achieve this, you need to evaluate two conditions simultaneously: whether the work status date is in the future (or today) and whether the salary increase is less than 26%. The AND function handles this dual logic.

When the conditions are met, the LEFT function extracts the characters before the comma. If the conditions fail, the RIGHT function extracts the characters after the comma.

1
Organize Your Data Columns

Ensure your data is structured with the employee name in cell A2, the work-status date in B2, the original salary in C2, and the new salary in D2.

2
Select the Target Cell

Click on the cell where you want the extracted name or surname to appear (for example, E2).

3
Input the Formula

Type or paste the following formula into the formula bar: =IF(AND(B2>=TODAY(),(D2-C2)/C2<0.26),LEFT(A2,FIND(",",A2)-1),RIGHT(A2,LEN(A2)-FIND(",",A2)))

4
Apply to Remaining Rows

Press Enter to see the result. Click the bottom-right corner of the cell and drag the fill handle down to apply the formula to the rest of the employee records.

Use a Nested Formula with IF, AND, LEFT, and RIGHT Functions
Adjusting for Different Name Formats: This formula assumes the name is formatted as 'FirstName, Surname'. If the separator is a space instead of a comma, replace "," with " " in all FIND functions within the formula.
Advanced Formula Support

Easily Handle Complex Formulas with WPS Spreadsheet

WPS Spreadsheet provides robust support for logical and text functions like IF, AND, LEFT, and RIGHT, making it simple to process conditional data effortlessly. It is an excellent tool for handling complex datasets with advanced formulas.

  1. 1. Open Your Workbook: Launch WPS Spreadsheet and open the file containing your employee data.
  2. 2. Select the Destination Cell: Click on the cell where you want the conditional name extraction to be displayed.
  3. 3. Use the Formula Builder: Go to the Formulas tab and click Insert Function. You can search for IF, LEFT, or RIGHT functions if you need guidance on the syntax.
  4. 4. Apply Your Logic: Paste your combined logical formula into the formula bar and press Enter. Double-click the fill handle to populate the entire column.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx, .xls).Includes a comprehensive built-in formula builder to help you construct complex logical statements easily.Free, lightweight, and offers smooth performance even when calculating formulas across thousands of rows.
microsoft office alternative - wps office

Frequently Asked Questions

How do I extract the first name if there is no comma in the name cell?

If the name is separated by a space (e.g., 'John Doe'), replace the comma in the FIND function with a space. For example, use =LEFT(A2, FIND(" ", A2)-1) to get the first name.

Why is the salary calculation returning a #DIV/0! error?

This error occurs if the original salary cell (C2) is empty or contains a zero. You cannot divide by zero in Excel. Ensure all original salary cells have valid numbers before applying the formula.

Can I adjust the formula for a different salary increase percentage?

Yes. To change the percentage threshold, locate the <0.26 part of the formula and replace it with your desired decimal value. For example, use <0.10 for a 10% threshold.

What if my text format puts the surname first, like 'Surname, FirstName'?

If the surname appears before the comma, simply swap the LEFT and RIGHT functions in the IF statement. The LEFT function will then extract the surname, and the RIGHT function will extract the first name.