Forum Discussion

danextian's avatar
danextian
Icon for Super User rankSuper User
9 years ago
Solved

[Expression.Error] We cannot convert the value #date(2017, 4, 3) to Type Text

Hi  All,   I'm trying  to extract the first date from a column. A cell contains text like this:   1/11/17 communication 1/10 communication 1/9 communication 1/6 communication 1/5-communicatio...
  • MarcelBeug's avatar
    MarcelBeug
    9 years ago

    Before the change, there is no error. After the change you get the error.

     

    This illustrates that code may work fine once generated, but my cause errors when data is adjusted.

     

    If you would recreate the code starting with Source = {"Marcel#(lf)Beug", #date(2017,3,4)}, convert to table and then split by delimiter (#(lf)), then the code would look very different, as the splitter functionality first converts the column to text:

     

    let
        Source = {"Marcel#(lf)Beug", #date(2017,3,4)},
        #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Converted to Table", {{"Column1", type text}}, "en-US"), "Column1", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
        #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}})
    in
        #"Changed Type"