Forum Discussion
[Expression.Error] We cannot convert the value #date(2017, 4, 3) to Type Text
- 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"
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"
I've learned from my mistake. After loading the data into the model, I should have set my data type first.
Well, I was actually under the impression that ABC123 was text instead of variant