Return a REAL blank cell in formula that will be ignored when sorted.

I'm running into a very annoying issue which is that Numbers seems to treat truly empty cells and cells that return "" (blank) differently when sorting a table...


For example, if I have a column where the formula returns various names if true and "" if false, when I sort the column by "Ascending", all the black rows will gather at the top (before the letter A).


On the other hand, if I erase the cells that return "" and then try again to sort either ascending or descending, the now truly empty cells (no formulas) just get ignored when sorted.


My question is: is there a way to get a formula to return something that will be ignored when sorting like an empty cell would?


Posted on Feb 2, 2024 11:28 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 3, 2024 11:15 AM

No matter what character you choose, it will sort like other characters. If it sorts to the bottom in an ascending sort, it will sort to the top in a descending sort. The only cells I see that sort to the bottom no matter what are blank cells and errors.


If you don't mind a bunch of error triangles, you could have the result of your formulas be an error instead of "". Any downstream formulas that reference those cells can use IFERROR instead of checking for "".


Or leave everything like it is but use a filter to filter out the rows with "" before or after sorting.

Similar questions

13 replies
Question marked as Top-ranking reply

Feb 3, 2024 11:15 AM in response to thegoddelusion

No matter what character you choose, it will sort like other characters. If it sorts to the bottom in an ascending sort, it will sort to the top in a descending sort. The only cells I see that sort to the bottom no matter what are blank cells and errors.


If you don't mind a bunch of error triangles, you could have the result of your formulas be an error instead of "". Any downstream formulas that reference those cells can use IFERROR instead of checking for "".


Or leave everything like it is but use a filter to filter out the rows with "" before or after sorting.

Feb 2, 2024 1:28 PM in response to thegoddelusion

First, something you didn't ask about. The sort rank/value is affected by the Format of the Cell. If the Format is Automatic, the number 10 will have a higher sort value than the number 9. If the Format is Text, the number 10 will have a lower sort value than the number 9. If the Format is Number, the sort will be the same as Automatic. You probably knew all that .


Further, and more to your point, Numeric entries have a lower sort value than String entries. Null Strings have the lowest rank among String entries. And, Strings beginning with number characters sort between Null Strings.and String entries that begin with alpha characters.


Lastly, as you have found, Blank Cells sort to the bottom. I believe that is because it is what most users would like to have happen, to "compress" all the empty rows out of the range of interest, to the bottom, where rows not yet used normally live.


If I wanted a computed string value to go the the bottom, I would give it a value of "zzzzz", and then conditionally format the cells with zzzzz to have zero opacity text so that their content would be invisible.


Jerry



Feb 2, 2024 6:52 PM in response to thegoddelusion

I'm with you that the null string should sort to the bottom like an actual blank cell, or it would at least be nice if that option was available. Unfortunately it does not. Neither does Excel.


There are no formulas that can create the equivalent of a blank cell. There were two text functions a few versions ago that could do it but that was because of a bug and that bug has been fixed.


I was hoping you could use a high-numbered non-visible unicode character (one of the various unicode space characters) in place of "" in your formula for your ascending sort but Numbers doesn't sort by ascii/unicode number so it doesn't help. They all get sorted to the top near the normal space character.


Other than filtering them out, I do not have a good solution.


Feb 3, 2024 5:25 AM in response to stfflspl

Hi Paul.


Not sure I understand. From my tests, if I make the formula return  via something like (...,"") then Numbers returns the replacement character � symbol which then gets sorted at the top when I chose the descending order.


For some reason, adding a highlighting rule for  suddenly fixes the � symbol and I can now see the returned  character in my table. But sorting the column descending still places all the  at the top of the table.



If instead I omit the "" via something like (...,), then I get an error and the formula does not work.



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Return a REAL blank cell in formula that will be ignored when sorted.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.