Oct 19 2021 12:13 PM
I have two columns that are connected and I want to sort by the second column, I want it sorted numerically but it keeps moving the numbers with the -1631 to the bottom of the list how do I fix this?
I have other columns on the same spreadsheet that I sort and I get a sort warning asking to read as numbers and I click this and it sorts fine.
Column A has Dollars
Column B has 49900
49815-1631
49816-1631
I want it to read 49815-1631
49816-1631
49900
50020-1631
and I want to be able to sort this while sorting Column A so it stays together. I have multiple columns on this spreadsheet that have two columns that are attached.
Oct 19 2021 05:01 PM - edited Oct 19 2021 05:07 PM
This is a guess.
I don't think Excel can read 49816-1631 as a number. That is to say, it's NOT a number, not until you (or Excel) does the subtraction. In the meantime, it is, by definition, text. Now, maybe it's a zip code (the way it's formatted, that occurs to me as a possibility). Are those other columns you refer to, where you get prompted to sort as numbers, also "numbers" mixed with text in the same field? If they really are just arabic numerals, even if formatted as text, then Excel is smart enough to treat as numbers, but what you have here, with the "-" dividing one set of numerals from another is text and can't be other than that.
As I said, it's a guess, but a semi-informed one. If you'd care to post the spreadsheet, or a portion of it, we can test my hypothesis.
Oct 20 2021 12:34 AM
@mathetes Hi. You will have to interpret the part before the minus sign as numeric.
c4 =IFERROR(NUMBERVALUE(LEFT([@Data];FIND("-";[@Data])-1));[@Data])
FIND("-";[@Data])-1)
Find the minus and substract one to find the numnur of digits.
LEFT([@Data];FIND("-";[@Data])-1))
Get that number of characters
NUMBERVALUE(LEFT([@Data];FIND("-";[@Data])-1))
Turn it into a numeric value
IFERROR(NUMBERVALUE(LEFT([@Data];FIND("-";[@Data])-1));[@Data])
If there is no minus FIND will generate an error. If so, return the value as is
Column D and E are optional depending on your need.
d4 =IFERROR(NUMBERVALUE(RIGHT([@Data];LEN([@Data])-FIND("-";[@Data])));0)
e4 =[@[Num 1st]]-[@[Num 2nd]]
[@Data] means same row in pyamas tables field Data.
If using an ordinary range, replace [@Data] with B4.
Generally, I prefer using MID since it's one function that can be used also for left and right. In the attached file though, LEFT and RIGHT are used.
Oct 21 2021 10:27 AM
Oct 21 2021 10:33 AM
@mathetesI have attached a sample of my spreadsheet as it is too large to attach more. I am trying to sort the numbers next to the dollar amounts while keeping the dollar amounts next to the numbers so columns E & F need to be sorted together I only want to sort from rows 6 through 16
Oct 21 2021 10:34 AM
Oct 21 2021 11:25 AM
@lxj190 Sort by the numeric column but look at the alphanumeric..?
...or turn the column into text format making the numbers treated as strings.
Menu Home: Number:
Oct 21 2021 01:06 PM
Oct 21 2021 10:23 PM
@lxj190 Right- if the invoice number not always begins numeric, then it will not work as proposed.
Good that the apostrophe (comment character) helps. And yet another possibility may be even more helpful;
=IFERROR(TEXT(F6:F18,"0"),F6:F18)
try to turn the data into text, and if it fails, treat it as already text.
Assuming Excel 365, there is only one formula, spilling the result. If Excel PDA/pre dynamic arrays, use
=IFERROR(TEXT(F6,"0"),F6)
and fill down.