Results 1 to 2 of 2

Thread: Changing and Learning Data Types

  1. #1
    Acolyte Charley's Avatar
    Join Date
    Jul 2017
    Posts
    56
    Articles
    0
    Excel Version
    365

    Changing and Learning Data Types



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I'm trying to create a function that returns the date parameter from a named cell in a workbook. Here's the code so far:

    Code:
    let
        Source = Excel.CurrentWorkbook(){[Name="MyDate"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}}),
        Column1 = #"Changed Type"{0}[Column1]
    in
        Column1
    The problem is that when I index on #"Changed Type" PQ turns the date type into the any type in the Column1 variable...I think.

    First question: Is there a PQ function that works like VBA's TypeName function so that I can KNOW what type Column1 is?

    Second question: How do I change the Column1 variable into a date value that my function can return...after I change the query into a function, of course.

    Thanks.

    Charley

  2. #2
    Acolyte Charley's Avatar
    Join Date
    Jul 2017
    Posts
    56
    Articles
    0
    Excel Version
    365
    Never mind. This works:


    Code:
    (DateCell as text) as date =>
    let
        Source = Excel.CurrentWorkbook(){[Name=DateCell]}[Content],
        //Source = Excel.CurrentWorkbook(){[Name="MyDate"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}}),
        DateValue = #"Changed Type"{0}[Column1]
    in
        DateValue

Tags for this Thread

Posting Permissions

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