+ Reply to Thread
Results 1 to 35 of 35

Excel sorting data incorrectly

  1. #1
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Excel sorting data incorrectly

    Hello,

    I do sort Z-A (want to see the values from the lowest to the highest) but it just randomly sorts it and it is the same with all the columns.

    How to fix this?
    Attached Images Attached Images

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Excel sorting data incorrectly

    These are not numbers - they are text that looks like numbers. Fix that, and your columns will sort as you want them to.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Excel sorting data incorrectly

    Looks to me like all your values are actually text looking like numbers (numbers right-align, text left aligns). You need to convert them - is this an import from another program?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Yes, this is an import from an API.

    Columns are categorized as General now, I made it to Number, problem still persists

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Excel sorting data incorrectly

    Formatting does not change the underlying cell contents, it is only a cosmetic change. You will need to convert the data.

    upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

  6. #6
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    so I just made new excel file and imported the data.

    so try to sort any column either A-Z or Z-A and you will see that excel does it completely random.
    If anyone could come up with a fix I would be very grateful
    Attached Files Attached Files

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Excel sorting data incorrectly

    We have already told you why this is not sorting as expected.

    To convert the TEXT numbers to real numbers, do this for each column (1 at a time)...
    1. highlight the column
    2. click Data tab/Text2Columns
    3. click Next/Next/Finish

    Repeat for all columns with numbers in them

    You should now be able to sort

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Excel sorting data incorrectly

    Select one of the columns - go to the data tab - select text to columns - click on next, next and finish without changing anything. Repeat for other columns.

  9. #9
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Thank you guys! It helped!

    Maybe you can explain me why it was like that and what this text to columns function does?

  10. #10
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    one more thing:

    when query is refreshed, it goes back to text; any way to make excel automatically convert it to numbers after it refreshes the query?

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    It looks as though that is a Power Query/Get and Transform query result, in which case you should alter the column type in Power Query.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  12. #12
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Could you please be more specific there?
    I am not that advanced in excel unfortunately
    Last edited by AliGW; 01-09-2018 at 07:42 AM.

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    Where are you importing the data from, and what are the steps you take to do so? In Power Query in 2010, when you select a column in the Query Editor, there is a dropdown at the top to select the data type for the column.
    PQ column type.jpg

  14. #14
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    THank you, thank kind of helped. Excel treats it as numbers now and I am able to sort it.
    However, when I transform it, even though I transform it to decimal number and hope to get some digits after the (.), it still gives me a whole number, and for example where it is a 0.091587 it would give me 91587

    How to fix this?
    Attached Images Attached Images
    Last edited by AliGW; 01-10-2018 at 02:07 AM. Reason: Unnecessary quotation removed.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Excel sorting data incorrectly

    Try one of the other options in the drop-down menu - decimal number or percentage.

  16. #16
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by AliGW View Post
    Try one of the other options in the drop-down menu - decimal number or percentage.
    Unfortunately does not work..

  17. #17
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    What is the data source? It looks like you are running into a problem with your regional settings- do they use a comma as the decimal separator?

  18. #18
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by xlnitwit View Post
    What is the data source? It looks like you are running into a problem with your regional settings- do they use a comma as the decimal separator?
    Data source - coinmarketcap.com
    https://coinmarketcap.com/

    Could you please be more specific with the regional settings and comma thing?

  19. #19
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    Normally in Excel would you enter one half as 0.5 or 0,5?

  20. #20
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    I would do it as 0.5

  21. #21
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    That's interesting. As far as I can see, the default settings for Lithuania in Windows are to use a comma as a decimal separator and a full stop as a grouping symbol. Have you changed your regional settings in Control Panel to something else, or have you told Excel to use different ones from your system settings? It looks like The Get and Transform engine is using the full stop as a grouping symbol, not a decimal point.

  22. #22
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by xlnitwit View Post
    That's interesting. As far as I can see, the default settings for Lithuania in Windows are to use a comma as a decimal separator and a full stop as a grouping symbol. Have you changed your regional settings in Control Panel to something else, or have you told Excel to use different ones from your system settings? It looks like The Get and Transform engine is using the full stop as a grouping symbol, not a decimal point.
    I have changed the setting in excel, was told to do so on this forum in order to get appropriate data on my other spreadsheet. (not using power query, but simply importing it from web: data>from web)

    is there any way to make changes to this get and transform data so it would fit my current settings?
    Or what should I do in order to achieve universal solution here?

  23. #23
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    I am just setting up a virtual machine with Lithuanian settings to test with. I'm guessing you don't want to simply alter your computer's regional settings in Control Panel, so it may be easiest to just do some string parsing in Power Query.

  24. #24
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    and what is this full stop as though?

  25. #25
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by xlnitwit View Post
    I am just setting up a virtual machine with Lithuanian settings to test with. I'm guessing you don't want to simply alter your computer's regional settings in Control Panel, so it may be easiest to just do some string parsing in Power Query.
    Thank you for your help here!

  26. #26
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    OK, so the issue is definitely your regional settings which is what the PQ engine defaults to using. You need to edit the query to bring up the PQ window, then click the dropdown arrow to the left of the Home tab, choose Options and Settings, then Query options. Now choose Regional Settings in the Current Workbook section, and change it to English (United States) rather than Lithuanian. You should then be able to simply convert any number columns to the relevant type.

  27. #27
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by xlnitwit View Post
    OK, so the issue is definitely your regional settings which is what the PQ engine defaults to using. You need to edit the query to bring up the PQ window, then click the dropdown arrow to the left of the Home tab, choose Options and Settings, then Query options. Now choose Regional Settings in the Current Workbook section, and change it to English (United States) rather than Lithuanian. You should then be able to simply convert any number columns to the relevant type.
    Man, thank you very much!!!
    This problem has been haunting me for few months and nobody knew the solution to it!

    Thank you, this was a tremendous help to me!

    Wish you all the best!

  28. #28
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    You're welcome, and thank you for the rep.

  29. #29
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    could explain a little bit what is it and why do they need to make it so complicated? :D

    so every region has their own approach to this decimal point thing?

  30. #30
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    Yes, different countries use different characters for decimal point and the thousands grouping. So most of Europe would write 1.234,00 whereas the UK and North America would write 1,234.00

  31. #31
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    ohh why make this so complicated, we should have universal solution to this :D

  32. #32
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel sorting data incorrectly

    Microsoft does- they just assume everyone is American.

  33. #33
    Forum Contributor
    Join Date
    06-18-2017
    Location
    Lithuania
    MS-Off Ver
    2016
    Posts
    177

    Re: Excel sorting data incorrectly

    Quote Originally Posted by xlnitwit View Post
    Microsoft does- they just assume everyone is American.
    Thank you once again for your tremendous help here and informative answers.

    I have another issue though, maybe you will know the solution to this one as well.

    I try to import API data from cryptopia.co.nz

    They have publicly issued their APIs here:
    https://www.cryptopia.co.nz/Forum/Thread/255

    Lets say I choose to import this one:
    https://www.cryptopia.co.nz/api/GetCurrencies

    When I do that, I get this.

    How to solve it?
    Attached Images Attached Images

  34. #34
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Excel sorting data incorrectly

    Please start a new thread for this completely different issue.

  35. #35
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Excel sorting data incorrectly

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot Tables Incorrectly Sorting Dates
    By Phronesis in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-06-2016, 03:49 PM
  2. Sorting Table Incorrectly?
    By shawnvw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2014, 04:12 PM
  3. Replies: 0
    Last Post: 02-24-2014, 11:27 AM
  4. Parsing CSV data incorrectly
    By Datagrunt in forum Excel General
    Replies: 3
    Last Post: 12-10-2009, 06:04 PM
  5. Data showing incorrectly on line chart
    By gobonniego in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-07-2006, 04:30 AM
  6. data sort incorrectly
    By Brainsurgery is easy when you know how. in forum Excel General
    Replies: 1
    Last Post: 11-09-2005, 03:10 PM
  7. Column sorting incorrectly
    By Melissa in forum Excel General
    Replies: 18
    Last Post: 10-13-2005, 04:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1