Changing and Learning Data Types

Charley

Member
Joined
Jul 29, 2017
Messages
64
Reaction score
0
Points
6
Excel Version(s)
365
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
 
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
 
Back
Top