+ Reply to Thread
Results 1 to 8 of 8

24 time conversion on custom column under Power Query - getting error

  1. #1
    Registered User
    Join Date
    06-18-2020
    Location
    Arizona
    MS-Off Ver
    Office 365
    Posts
    75

    24 time conversion on custom column under Power Query - getting error

    Hello,

    I am trying to add a custom column to my power query to complete a 24H conversion of the times in Column5.2 using the following formula, but I receive an error and I am not sure why. Does it have something do with the way power query treats time?

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thanks!
    Attached Images Attached Images

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: 24 time conversion on custom column under Power Query - getting error

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: 24 time conversion on custom column under Power Query - getting error

    I would keep the data and time not split but in the same column. Then I would apply the Number.From(#datetime([Column])) and then split the column to show the date number and the time number (the decimal). Then run your if statement on the number (decimal)

  4. #4
    Registered User
    Join Date
    06-18-2020
    Location
    Arizona
    MS-Off Ver
    Office 365
    Posts
    75

    Re: 24 time conversion on custom column under Power Query - getting error

    I have added the workbook, sorry about that!

    I think I am following what you're saying, and can keep the date/time data in one column. Can you show me what the code would look like in the PQ?
    Attached Files Attached Files

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: 24 time conversion on custom column under Power Query - getting error

    When I bring your table into PQ as a new query, it automatically reformats the time to a decimal. I tried to load the original data but that apparently came from a different file to which I didn't have access. For me to help you it will be necessary to have the original or a simulation of the original to upload.

  6. #6
    Registered User
    Join Date
    06-18-2020
    Location
    Arizona
    MS-Off Ver
    Office 365
    Posts
    75

    Re: 24 time conversion on custom column under Power Query - getting error

    Original file is attached - thank you for taking a look!
    Attached Files Attached Files

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: 24 time conversion on custom column under Power Query - getting error

    I am unable to reproduce your issue. When I add your file to PQ, it automatically reformats the Time to a decimal, which is what you want to be able to do with your file. See the picture showing the file in PQ.
    Attached Images Attached Images

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: 24 time conversion on custom column under Power Query - getting error

    Please try

    = if [Column5.2] < #time(12,0,0) and [Column5.3] = "PM" then [Column5.2] + #duration(0,12,0,0) else [Column5.2]

    time to compare with time, and duration when calculate with time

+ 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] Power Query Custom Column syntax help Part 2!
    By L.J. in forum Excel General
    Replies: 4
    Last Post: 11-13-2019, 02:30 PM
  2. [SOLVED] Power Query Custom Column syntax help
    By L.J. in forum Excel General
    Replies: 6
    Last Post: 11-12-2019, 03:45 PM
  3. Custom Permutations Column in Power Query from two columns in the same Query
    By PaintPaddy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2019, 02:48 PM
  4. [SOLVED] Power Query Custom Column Formula
    By whiskeybravo91 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-06-2018, 11:10 AM
  5. Power Query Custom Column Formula
    By whiskeybravo91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2018, 09:57 AM
  6. [SOLVED] Insert a date value as a Custom Column in Power Query
    By heytherejem in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-28-2018, 12:42 PM
  7. Help with Power Query Custom Column Formula
    By travis.cook21 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-16-2016, 01:45 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