Forum Discussion
"Month Number" Formula
- 4 years ago
Hi Anonymous ,
That's a pity... since there is no M Power Query function to reverse MonthNames to Numbers... There is always the possibility for twelve if clauses I suppose, but here another one that you might consider sufficient:
Create a new custom column with the following code:
Date.Month ( Date.FromText ( "1 " & [MonthName] & " 2022" ) )
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMK00sqlSK1YlWcktNKoJzfBOLkjPALMeCoswcqBhEzqs0LxXKyIGIOJamlxaXgJnBqQUlqblJqUVgnn9yST6M7ZdfhpBwSU2GcmIB", 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", "MonthNumber", each Date.Month ( Date.FromText ( "1 " & [MonthName] & " 2022" ) )) in #"Added Custom"Does this work for you? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Unfortunately, I do not.
- tackytechtom4 years ago
Most Valuable Professional
Hi Anonymous ,
That's a pity... since there is no M Power Query function to reverse MonthNames to Numbers... There is always the possibility for twelve if clauses I suppose, but here another one that you might consider sufficient:
Create a new custom column with the following code:
Date.Month ( Date.FromText ( "1 " & [MonthName] & " 2022" ) )
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMK00sqlSK1YlWcktNKoJzfBOLkjPALMeCoswcqBhEzqs0LxXKyIGIOJamlxaXgJnBqQUlqblJqUVgnn9yST6M7ZdfhpBwSU2GcmIB", 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", "MonthNumber", each Date.Month ( Date.FromText ( "1 " & [MonthName] & " 2022" ) )) in #"Added Custom"Does this work for you? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/