Function Problems

How to Extract Root Category Before the First Delimiter in Excel

Maira MehtabMaira Mehtab Nov 4, 2026 871 views

Question details

The user wants to extract the root category text that appears before the first double-colon delimiter (::) in an Excel calculated column, ensuring that original values without delimiters remain unaffected.

How to Extract Root Category Before the First Delimiter in Excel
Product
Excel
Device & OS
not provided
Scenario
Creating a calculated column to clean up or categorize data containing specific text delimiters.
Observed behavior
The user needs to isolate the root category string before the delimiter without returning errors for cells that don't contain the delimiter.
Before you start

Ensure your target column data is formatted consistently. Identify the exact character or string that separates your text (e.g., a double-colon '::', comma, or hyphen) so you can correctly adjust the formula.

Solution 1Recommended

Use Text Extraction Formula with TRIM, LEFT, and SUBSTITUTE

This method uses a combination of built-in Excel text functions to cleanly isolate the string before the delimiter without breaking cells that lack delimiters.

By replacing the target delimiter with a large block of blank spaces, extracting the leftmost portion of the new string, and then removing the extra spaces, this formula safely retrieves the root text.

It gracefully handles cells that do not contain the delimiter by simply returning the original text unchanged.

1
Select the target cell

Click on the first blank cell in your calculated column where you want the extracted root category to appear.

2
Enter the extraction formula

Type the formula =TRIM(LEFT(SUBSTITUTE([@Category],"::",REPT(" ",255)),255)) into the formula bar. Replace [@Category] with your actual cell reference (for example, A2).

3
Adjust the delimiter

If your text uses a different delimiter like a comma (,) or a hyphen (-), change the "::" in the formula to match your specific delimiter.

4
Apply and fill down

Press Enter to execute the formula. Click the cell again, hover over the bottom-right corner until the cursor becomes a cross, and drag it down to apply the extraction to the rest of the column.

How this formula works: SUBSTITUTE replaces your delimiter with 255 empty spaces. LEFT grabs the first 255 characters (capturing the target text plus spaces), and TRIM removes all trailing spaces to give you clean text.
Advanced Data Cleaning

Extract Text and Analyze Data Easily with WPS Spreadsheet

WPS Spreadsheet fully supports Excel's advanced text functions, including TRIM, LEFT, and SUBSTITUTE. You can easily clean, organize, and extract your data without worrying about formula compatibility.

  1. 1. Open your data file: Launch WPS Spreadsheet and open the document containing your category data.
  2. 2. Input the formula: Select a blank cell next to your text data and paste the formula =TRIM(LEFT(SUBSTITUTE(A2,"::",REPT(" ",255)),255)).
  3. 3. Auto-fill the column: Press Enter, then double-click the small green fill handle at the bottom-right corner of the cell to instantly apply the formula down the entire column.
100% compatible with Microsoft Excel formulas and .xlsx file formats.Advanced text manipulation and data cleaning tools built right in.Lightweight software that runs smoothly on Windows, Mac, and Linux.Free to download and use for all your data analysis needs.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use Text to Columns instead of a formula to extract the root category?

Yes. You can highlight your data, go to the Data tab, and select 'Text to Columns'. Choose 'Delimited', enter your custom delimiter (like '::'), and finish. However, unlike a formula, this will physically split your source data into separate columns.

How do I extract text after the first delimiter instead of before it?

To extract text after the delimiter, you can use a combination of RIGHT, LEN, and FIND functions. For example: =RIGHT(A2, LEN(A2) - FIND("::", A2) - 1).

What if my cell contains multiple different delimiters?

If you are dealing with different delimiters (like commas and hyphens in the same column), you may need to nest multiple SUBSTITUTE functions to standardize the delimiter first before extracting, or use the newer TEXTSPLIT function if your version supports it.

Why does the formula use the number 255?

The number 255 is used as an arbitrarily large number that is guaranteed to be longer than the text you want to extract. This ensures the LEFT function safely captures your entire root category word alongside the added blank spaces.