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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SJHALANI
Helper I
Helper I

Convert numbers to Months

Hello,
I have a column where numbers are written from 0 to 11. Now I want to create a column where 0 should be replaced with the current month, for eg, February, and 1 should be replaced by next month, i.e., March and so on. I am not able to figure out a way to do this. Any help would be greatly appreciated. Thanks! 

Current ColumnOutput wanted
0February
2April
1March
12January
11December
0February

 

1 ACCEPTED SOLUTION

NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM\'yy","en"))

View solution in original post

5 REPLIES 5
wdx223_Daniel
Super User
Super User

NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM","en"))

Thanks! This is working. Suppose if I also want to add Year to it the output column, then how can this be done. Reason I now realise I want year is because both 0 and 12 yield the same output "February", however the latter should be February'24

NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM\'yy","en"))

Thank you! You are Awesome. I will mark this as a solution.

However, one last thing - When I build a chart using these Month-Year combination, the axis isn't sorted automatically based on the chrnology of months. Any quick way to do this?
TIA!

SJHALANI_0-1675754792000.png

 

you need set "SortBy Column" in the table page, and select the [Current Column]

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Kudoed Authors