Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I need to transform the Month name to month number, In same column or if not possible in aditional column. I tried the following custom column but doesn't work.
Month Name Step:
if I change Data type into Date it gives an error:
Solved! Go to Solution.
Please try my sample in a new query and if that works then you can tweak to your needs in your query.
FYI, I change the column as "Month Name"
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMK00sqlSK1YlWcktNKoJzfBOLkjPALMeCoswcqBhEzqs0LxXKyIGIOJamlxaXgJnBqQUlqblJqUVgnn9yST6M7ZdfhpBA4bikJkM5sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Month Name" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month Name", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Month Number", each Date.Month(Date.FromText([Month Name], [Format="MMMM"])), Int64.Type)
in
#"Added Custom"
You can do as another column
Table.AddColumn(#"Changed Type", "Month Number", each Date.Month(Date.FromText([MonthName], [Format="MMMM"])), Int64.Type)
Sample:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMK00sqlSK1YlWcktNKoJzfBOLkjPALMeCoswcqBhEzqs0LxXKyIGIOJamlxaXgJnBqQUlqblJqUVgnn9yST6M7ZdfhpBA4bikJkM5sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MonthName = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"MonthName", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Month Number", each Date.Month(Date.FromText([MonthName], [Format="MMMM"])), Int64.Type)
in
#"Added Custom"
Please try my sample in a new query and if that works then you can tweak to your needs in your query.
FYI, I change the column as "Month Name"
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMK00sqlSK1YlWcktNKoJzfBOLkjPALMeCoswcqBhEzqs0LxXKyIGIOJamlxaXgJnBqQUlqblJqUVgnn9yST6M7ZdfhpBA4bikJkM5sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Month Name" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month Name", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Month Number", each Date.Month(Date.FromText([Month Name], [Format="MMMM"])), Int64.Type)
in
#"Added Custom"
User | Count |
---|---|
70 | |
70 | |
34 | |
23 | |
22 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |