Forum Discussion
Alphanumeric sorting
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.
8 Replies
- mathetesSilver Contributor
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.
- lxj190Copper Contributor
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
- bosinanderIron Contributor
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.
- lxj190Copper ContributorThank you for this response but this won't work for what I am trying to do. I already tried it I need the -1631 to stay with the number without losing my sort