+ Reply to Thread
Results 1 to 13 of 13

Dates Not Sorting Correctly in Pivot Table

  1. #1
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Dates Not Sorting Correctly in Pivot Table

    Here is how my Pivot Table is set up.

    \1
    \1
    \1

    The way my dates are derived in the source data comes from an equation that converts the UNIX timestamp in Column C to PST.

    =IF(ISBLANK(C2),"",(C2/86400)+25569+($H$1/24))

    When I group by day, and attempt to sort, it changes the date format and will not sort correctly. Any ideas here?
    Attached Images Attached Images
    Last edited by eightythree; 04-13-2014 at 02:24 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dates Not Sorting Correctly in Pivot Table

    Hi,

    Please upload the workbook rather than pictures - see guidance in rule area. Most of us are reluctant to recreate your workbook when you have one available and you'll receive more responses.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Dates Not Sorting Correctly in Pivot Table

    Ok I attached the worksheet to this post. Thanks for your help in advance!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Dates Not Sorting Correctly in Pivot Table

    Any ideas here?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dates Not Sorting Correctly in Pivot Table

    Hi,

    The dates appear to be in descending order but without showing the year. The Date column in the table is actually a Date & Time number, i.e. one containing a decimal value. If you wrap the date formula in an INT() function then refresh the PT you will see the year appearing. Is that what you mean?

  6. #6
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Dates Not Sorting Correctly in Pivot Table

    The problem is that in the Pivot Table, the dates will not order correctly and the date format (dd-mmm) cannot be changed. The source data includes date and time as you mentioned, so Excel should be able to sort it correctly.

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Dates Not Sorting Correctly in Pivot Table

    Don't know what is wrong. I opened the file - indeed dates look like sorted "text way" - descending order 8... 7... 6.... 5... 10... 1 is earlier in alphabet than 5 :-)
    but I right clicked on table - choosen "Refresh" and ... magic! It's sorted as dates not as text. So I did not investigated any further.

    May be try to refresh your pivot and it works also for you?
    Best Regards,

    Kaper

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dates Not Sorting Correctly in Pivot Table

    Quote Originally Posted by eightythree View Post
    The problem is that in the Pivot Table, the dates will not order correctly and the date format (dd-mmm) cannot be changed. The source data includes date and time as you mentioned, so Excel should be able to sort it correctly.
    Have you tried the solution I offered you in post #5.

    As you correctly indicate the source data includes a TIME, and therein I believe lies your problem. A PT can group by Years, Qtrs. Months, but not Hours, and indeed it seems to object to cells which carry a decimal time value when Grouping. Hence my suggestion to use the INT() function.

  9. #9
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Dates Not Sorting Correctly in Pivot Table

    I wrapped the formula in the INT() function, then on the data source I set the format to General. So in the source data, the dates appear as numbers. On the Pivot table, I set the formatting to date, and it seems to work. However, when I attempt to group the dates in different segments, IE Months/Days/Weeks, it attempts to group them as numbers not dates anymore. Such a strange bug.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dates Not Sorting Correctly in Pivot Table

    Hi

    I somehow doubt you're seeing a bug in what's a fairly common use of date numbers and groupings in Pivot Tables. Upload your workbook so that we can take a look and explain what you are expecting to see.

  11. #11
    Registered User
    Join Date
    03-28-2014
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Dates Not Sorting Correctly in Pivot Table

    I attached the updated worksheet.

    As you can see, I wrapped the dates in the INT() function on the source data and formatted them as General. The dates now sort correctly and with the correct date format. However, if I attempt to group them, it tries to group by numbers, not by dates.
    Attached Files Attached Files

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dates Not Sorting Correctly in Pivot Table

    Hi,

    Seems the problem is associated with the format chosen for dates. It seems the Grouping functionality is not happy with formats preceded by an * used to ensure dates change according to regional settings.

    See attached
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-20-2015
    Location
    New York, US
    MS-Off Ver
    2007
    Posts
    1

    Re: Dates Not Sorting Correctly in Pivot Table

    So i had the same problem and i solved it in 2 ways (that one way worked for 3 PT and the other one for the forth one):
    1. Changed in the source to be Date as it was General before. This was suggested also before.
    2. Ungroup your PT, sort by the ungrouped dates, and then Group again. For some crazy reason it did the trick.

    Hope it helped.
    Joe

+ 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. Sorting Dates in a Pivot Table is not working
    By Excel_vba in forum Excel General
    Replies: 1
    Last Post: 10-09-2012, 02:31 PM
  2. Sorting dates in Pivot table
    By scuba2x2 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 09-13-2012, 07:45 PM
  3. Sorting Dates in a Pivot Table
    By johncassell in forum Excel General
    Replies: 1
    Last Post: 07-11-2011, 06:31 AM
  4. Pivot table no longer sorting correctly (2003)
    By mlk in forum Excel General
    Replies: 0
    Last Post: 02-28-2011, 02:15 PM
  5. [SOLVED] Pivot Table not sorting correctly
    By Marian in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-28-2006, 12:20 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