How to Make XLOOKUP Blank Results Sort Like Empty Cells
Question details
The user wants XLOOKUP formula results that return empty strings to sort at the bottom of the dataset, matching the behavior of genuinely empty cells.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Sorting a dataset alphabetically where some rows contain XLOOKUP formulas returning empty strings for blank project names.
- Observed behavior
- During an A-to-Z sort, formula results containing empty strings appear at the top before other text values, rather than sorting at the bottom like truly empty cells.
Keep in mind that no spreadsheet formula can return a genuinely empty cell. An empty string ("") is evaluated as a text value, which dictates its position during a standard alphabetical sort.
Use a Helper Column for Multi-Level Sorting
By creating an additional column that identifies formula-generated blanks, you can force rows with empty strings to sort at the bottom.
Since empty strings sort before standard text, you must use a custom sorting logic. A helper column assigns a numeric weight to blank formula results, overriding the default text sort order.
Insert a new column next to your XLOOKUP data and name it 'Sort Key'.
Enter the formula =IF(B2="", 1, 0) into the first cell of the helper column (assuming B2 is your XLOOKUP result) and drag it down to fill the column.
Select your entire data range, navigate to the Data tab on the ribbon, and click 'Sort' to open the Custom Sort dialog box.
Add a primary sort level by 'Sort Key' (Smallest to Largest), then add a secondary sort level by your XLOOKUP column (A to Z), and click OK.

Convert Formulas to Values and Clear Empty Strings
If you do not need the XLOOKUP formulas to update dynamically in the future, converting them to static values allows you to completely delete the empty strings.
Effortlessly Manage Formulas and Sorting in WPS Spreadsheet
WPS Spreadsheet provides robust, highly compatible tools to handle complex functions like XLOOKUP and multi-level data sorting, allowing you to organize your data exactly as needed.
- 1. Open your file in WPS: Launch WPS Spreadsheet and open your .xlsx workbook containing the XLOOKUP formulas.
- 2. Add a helper column: Insert an adjacent column and use the IF function to tag empty strings vs. populated text.
- 3. Use custom sort: Navigate to Data > Sort to effortlessly set up your primary and secondary sort criteria.
- 4. Save with full compatibility: Save your optimized workbook; WPS maintains perfect formula compatibility with standard Office formats.

Frequently Asked Questions
Why does my XLOOKUP formula return a zero instead of an empty string?
By default, if the source cell is genuinely blank, XLOOKUP will return a 0. To force it to return an empty string instead, you can concatenate an empty string to the formula (e.g., =XLOOKUP(...) & "") or wrap it in an IF statement.
Can any spreadsheet formula return a genuinely empty cell?
No. Any cell containing a formula is not empty by definition. Even if the output is an empty string (""), the spreadsheet engine treats it as a text value, which influences sorting and filtering behaviors.
Will formatting the column as Text fix the sort order of empty strings?
No. Cell formatting only changes the visual display of the data. The underlying empty string ("") remains a zero-length text value and will still sort before standard letters in an ascending sort.
Does using an Excel Table automatically fix the blank sorting issue?
No. While Excel Tables provide structured references and automatic formula expansion, they do not change the fundamental rule that an empty string sorts before regular text values.




