Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cristianml
Post Prodigy
Post Prodigy

Transform Text to Month number query editor

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.

 

cristianml_0-1649437281774.png

 

Month Name Step:

cristianml_1-1649437352606.png

 

if I change Data type into Date it gives an error:

cristianml_2-1649437389052.png

 

 

 

 

 

 

 

1 ACCEPTED 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"

 

View solution in original post

3 REPLIES 3
sevenhills
Super User
Super User

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"

 

 

 

sevenhills_0-1649439187622.png

 

Hi @sevenhills ,

it doesn't work

 

cristianml_0-1649440248032.png

 

cristianml_1-1649440324513.png

 

 

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"

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.