+ Reply to Thread
Results 1 to 8 of 8

Not sorting correctly

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-04-2016
    Location
    dallas tx
    MS-Off Ver
    365 (15.0.5501.1000)
    Posts
    541

    Not sorting correctly

    I have a data set that I am trying to sort by time oldest to newest. The time is in column D of the example. It is not sorting correctly as the 24:00:00 times are not moving to the end of the day. I performed a find and replace with the times to turn 00:00:00 into 24:00:00 respectively. The numbers are displaying differently and I am not sure why and that may have something to do with it. How can I get this to numerically sort correctly?
    Attached Files Attached Files

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

    Re: Not sorting correctly

    Could you please attach a copy of the data BEFORE you fiddled with it?
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    04-04-2016
    Location
    dallas tx
    MS-Off Ver
    365 (15.0.5501.1000)
    Posts
    541

    Re: Not sorting correctly

    here you go
    Attached Files Attached Files
    Last edited by AliGW; 07-30-2021 at 07:42 AM. Reason: PLEASE don't quote unnecessarily!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,273

    Re: Not sorting correctly

    Explain to us why you would want these at the end of the list when they are at the start of the day:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 3517A101.021 00:11:33 33S055 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019249278 0001
    2
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 2599001.020 00:24:37 41N012 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019187098 0001
    3
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 3517A101.021 00:34:19 33S055 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019249272 0001
    Sheet: Sheet1

    I really don't understand why you'd want them at the wrong end of the day.

  5. #5
    Forum Contributor
    Join Date
    04-04-2016
    Location
    dallas tx
    MS-Off Ver
    365 (15.0.5501.1000)
    Posts
    541

    Re: Not sorting correctly

    Quote Originally Posted by AliGW View Post
    Explain to us why you would want these at the end of the list when they are at the start of the day:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 3517A101.021 00:11:33 33S055 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019249278 0001
    2
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 2599001.020 00:24:37 41N012 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019187098 0001
    3
    HUNTJ @20\QConfirmed Without Difference@ Confirmed Without Difference 3517A101.021 00:34:19 33S055 3004545497 200 @5B\QPick and Transport. Confirmed@ Pick and Transport. Confirmed 05 0019249272 0001
    Sheet: Sheet1

    I really don't understand why you'd want them at the wrong end of the day.
    I didn't grab the whole thing. this is the same work day by shift but is really two days. Shift starts at 1:30 PM on the 27th and ends after midnight on the 28th.
    I have to move them to the end of the day.
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,686

    Re: Not sorting correctly

    I don't see any records that are shown as 24:00:00. I formatted the column D as Time and they seem to sort ok for me. Could not replicate your indicated issue.

    EDIT: Concur with Ali's Question
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,686

    Re: Not sorting correctly

    With Power Query, I was able to combine the dates and times and then sort them.
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type time}, {"Column5", type text}, {"Column6", Int64.Type}, {"Column7", Int64.Type}, {"Column8", type text}, {"Column9", Int64.Type}, {"Column10", Int64.Type}, {"Column11", Int64.Type}, {"Column12", type date}, {"Column13", Int64.Type}}),
        #"Inserted Merged Date and Time" = Table.AddColumn(#"Changed Type", "Merged", each [Column4] & [Column12], type datetime),
        #"Sorted Rows" = Table.Sort(#"Inserted Merged Date and Time",{{"Merged", Order.Ascending}})
    in
        #"Sorted Rows"
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Not sorting correctly

    One simple way is to create a helper column in N and put this formula in =L1+D1 (change the cell format to "m/d/yy hh:mm:ss", if you desire), then sort this column. Remember to turn on automatic calculation mode before sorting (Formulas > Calculation Options > Automatic).

+ 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. [SOLVED] columns not sorting correctly
    By joe313 in forum Excel General
    Replies: 5
    Last Post: 07-04-2020, 03:36 AM
  2. [SOLVED] Power Query Sorting by Date not sorting correctly
    By kersplash in forum Excel General
    Replies: 5
    Last Post: 08-20-2018, 02:59 AM
  3. [SOLVED] Sorting numbers... correctly
    By LonesomeJoe in forum Excel General
    Replies: 6
    Last Post: 06-11-2014, 04:59 PM
  4. numbers not sorting correctly
    By JMTMayor in forum Excel General
    Replies: 15
    Last Post: 08-01-2013, 12:00 PM
  5. sorting not working correctly
    By jjbigfish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-27-2012, 02:46 PM
  6. [SOLVED] Date not sorting correctly....
    By DeeLaa77 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-28-2012, 08:50 AM
  7. Not sorting correctly
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2008, 03:48 PM

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