+ Reply to Thread
Results 1 to 7 of 7

Power Query custom function date type

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    768

    Power Query custom function date type

    Hi,
    can you define the output data type in a custom function; I thought , seemingly wrongly, you put it outside the brackets,
    so

    Please Login or Register  to view this content.
    when used as an addcolumn the new column would be type number? it's not, so can it be done and what does a data type out side of hte function
    mean ? ( x as type ) as type =>

    Richard.

  2. #2
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    768

    Re: Power Query custom function date type

    I seem to have been right, but was expecting the column data type to reflect this.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Power Query custom function date type

    Column data type and data type of value is separate.

    For an example, column could have mixed data type (though not recommended), having number and text etc.

    Value will either be specific type or untyped. Not multiple.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  4. #4
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    768

    Re: Power Query custom function date type

    Yes, I have now realized that, just as experiment had output for a number as text and so when eg X * 10 , got error,

    is there a way to add the column type ? i have done it for things like this

    Please Login or Register  to view this content.
    but this works on the whole table, if you want to 'add column' i tried;

    Please Login or Register  to view this content.
    and due to the comma, 10, type , it (i think) thinks you are starting an new variable,
    don't know if there is a way around this?
    will marks this up, thanks for the help.

    Richard.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Power Query custom function date type

    First one should be find for adding column. You just need to invoke it within Advanced Editor.

    If you want to go the 2nd route...
    Don't declare type in function.
    But declare it in AddColumn() where you invoke the function.
    Please Login or Register  to view this content.
    Then when you addcolumn by invoking function.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    768

    Re: Power Query custom function date type

    Thanks,

    Richard.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,966

    Re: Power Query custom function date type

    Just be aware that doing that doesn't actually convert or validate any of the data in that column to match the type.
    Everyone who confuses correlation and causation ends up dead.

+ 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 Function colum as text
    By Dicken in forum Office 365
    Replies: 2
    Last Post: 05-15-2024, 01:41 PM
  2. Power Query Custom replacer function
    By Dicken in forum Office 365
    Replies: 10
    Last Post: 12-03-2023, 12:03 PM
  3. How to update a custom function in Power Query
    By MangoFresh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-10-2023, 08:58 AM
  4. Power query adding date type to code
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 03-17-2023, 03:59 PM
  5. Power Query Custom function for running total
    By Dicken in forum Office 365
    Replies: 6
    Last Post: 10-29-2022, 10:58 AM
  6. Power query Custom function / parameter query
    By Dicken in forum Office 365
    Replies: 0
    Last Post: 03-23-2022, 10:41 AM
  7. Power Query - Invoke Custom Function
    By leukep in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2017, 02:18 PM

Tags for this Thread

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