Forum Discussion
Format date directly in the function
- 4 years ago
= Table.AddColumn(#"Changed Type", "Start of Month", each Date.From(Text.From([yyyymm])&"01"), type date) - Anonymous4 years ago
Hi Spigaw ,
Based on your M synatx, It seemed that the data type has changed from text to Number firstly by default ,which is not necessary.
So please delete the Changed type step in order to simplify your code and then use the following synatx in the Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMrBUitWBsAwNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test = _t]), #"Added Custom" =Table.TransformColumnTypes( Table.AddColumn(Source, "Custom", each Date.From(#date(Number.FromText(Text.Start([Test],4)),Number.FromText(Text.End([Test],2)),1)) ),{{"Custom", type date}}) in #"Added Custom"Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Spigaw ,
Based on your M synatx, It seemed that the data type has changed from text to Number firstly by default ,which is not necessary.
So please delete the Changed type step in order to simplify your code and then use the following synatx in the Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMrBUitWBsAwNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test = _t]),
#"Added Custom" =Table.TransformColumnTypes( Table.AddColumn(Source, "Custom", each Date.From(#date(Number.FromText(Text.Start([Test],4)),Number.FromText(Text.End([Test],2)),1)) ),{{"Custom", type date}})
in
#"Added Custom"
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.