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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ana_cordeiro
Regular Visitor

Replace Number by text

Hello,

 

I'm replace the Numbers os one Month column by Text (replane 1 by January, 2 by February...).

 

When I try replace 10 by October, 11 by November and 12 by December, appear attachment error.

 

Snap 2019-07-16 at 15.33.25.png

 

Can help me?

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @ana_cordeiro ,

 

To create a custom column as below.

 

Date.MonthName(#datetime(2011, [monthno], 1, 5, 0, 0), "en-US")

mon.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzMGkOJi3ApCWYNDSAUBDdhkDtsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [monthno = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"monthno", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.MonthName(#datetime(2011, [monthno], 1, 5, 0, 0), "en-US"))
in
    #"Added Custom"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

another option
Date.ToText(#date(2022, [MonthNumber], 1), "MMMM", " en-US")

Hi Ahmedx

 

Your suggested code works for me. Thank you so much!

And thanks for the very quick response too. 

v-frfei-msft
Community Support
Community Support

Hi @ana_cordeiro ,

 

To create a custom column as below.

 

Date.MonthName(#datetime(2011, [monthno], 1, 5, 0, 0), "en-US")

mon.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzMGkOJi3ApCWYNDSAUBDdhkDtsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [monthno = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"monthno", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.MonthName(#datetime(2011, [monthno], 1, 5, 0, 0), "en-US"))
in
    #"Added Custom"
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Tahreem24
Super User
Super User

Hi @ana_cordeiro ,

 

Its quite unknown which formula you are using to map month number with month name. I suggest you to use the SWITCH expression to accomplish your requirement.

 

MonthName = SWITCH('Month'[MonthNumber],1,"January",2,"Febuary",3,"March",4,"April",5,"May",6,"June",7,"July",8,"August",9,"September",10,"October",11,"November",12,"December","Invalid")
Month.PNG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

STM4508_0-1671604654288.png

Hi, I copied in the string of code, but there is error in the code. Can someone help?

vinaypugalia
Resolver I
Resolver I

Hello,

 

Could you please share some sample data & the expression you have written to get the required text?

This will give anyone who wants to help you to get more insight & guide you further.

 

Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.