Forum Discussion

KBD's avatar
KBD
Helper III
1 year ago

simple text to date

Hello All:

 

I have a simple issue, but yet I cannot crack it. ðŸ¤”

Have a CSV file with a couple of date and date/time attributes.

Therefore they need to be converted to Date and Date/Time.

Could not figure out how to upload the CSV file.

Can we upload files?

 

In Power Query in an Azure Data Factory the CSV file loads fine

 

 

The souce data (INSTALLDATE) seems to have loaded fine and my create a new attribute (InstallD) seems to have worked.

I used "Add Column--> Custom Col"  to create the col.

 

 

But I geetting an error message:

UserQuery : Expression.Error: The Power Query Spark Runtime does not support the function (collection as any, fieldName as any) as any => (...) .

 

Cannot Validate   

Do not have a clue why this went sideways.

 

Your kind assistance is requested.

 

Best Regards

 

KD

 

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Have you tried just using the Get data dialogue and choosing text file?

     

    --Nate

    • KBD's avatar
      KBD
      Helper III

      Are you repling to the correct quetion?

      The issue here is simple text to date converion.

       

      KD

    • KBD's avatar
      KBD
      Helper III

      Hello:

       

      Ripped out the steps, basically started over.  

      PQ is calic'ing the new col and the data looks correct.

      Code looks like this:

      Table.TransformColumnTypes(Table.AddColumn(Source, "InstallD", each DateTime.FromText([INSTALLDATE], [Format = "yyyy-MM-dd", Culture = "en-us"])), {{"InstallD", type date}})
       
      Will not validate.
      Error message:
      UserQuery : Expression.Error: The Power Query Spark Runtime does not support the function (collection as any, fieldName as any) as any => (...) .
       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Yeah. Two things. Table.TransformColumnTypes needs a function, like Date.From, not "type date". But instead of using Table.TransformColumnTypes, you can just add type date as the last parameter to the Table.AddColumn function, like

     

    ["en-us"]), type datetime)

     

    --Nate

    • KBD's avatar
      KBD
      Helper III

      This is what I specified in the Custom Com diolog

       

      shows this in the code window:

      Table.TransformColumnTypes(Table.AddColumn(Source, "InstallD", each DateTime.FromText([INSTALLDATE], [Format = "yyyy-MM-dd", Culture = "en-us"])), {{"InstallD", type date}})
       
      Will not validate.
      Error message:
      UserQuery : Expression.Error: The Power Query Spark Runtime does not support the function (collection as any, fieldName as any) as any => (...) .
       
       
      • KBD's avatar
        KBD
        Helper III

        Please note I am not writing the code, Custom Col dialog is generating the code.

         

        KD

  • Anonymous's avatar
    Anonymous
    Not applicable

    Just go into the formula bar and update the code as above. You are using a type enumeration where a function is required.

     

    --Nate

    • KBD's avatar
      KBD
      Helper III

      I am working in Azure in a Pipeline, in a PowerQuery step.

      I did my conversion over again.  No progress.

       

      Can somebody tell me exactly what the ExpressionError means?

       

      Read through this:  Data wrangling functions in Azure Data Factory - Azure Data Factory | Microsoft Learn

      Noticed this:

      Table.TransformColumnTypesThis is supported in most cases. The following scenarios are unsupported: transforming string to currency type, transforming string to time type, transforming string to Percentage type and tranfoming with locale.

      Above it says transforming string to time type is NOT supported.   Maybe string to date is not supported.

       

      Your kind assistance is requested.

       

      KD