Forum Discussion
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 Column | Output wanted |
| 0 | February |
| 2 | April |
| 1 | March |
| 12 | January |
| 11 | December |
| 0 | February |
NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM\'yy","en"))
5 Replies
- wdx223_DanielCommunity Champion
NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM","en"))
- SJHALANIHelper I
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
- wdx223_DanielCommunity Champion
NewStep=Table.AddColumn(PreviousStepName,"Output wanted",each DateTime.ToText(Date.AddMonths(DateTime.LocalNow(),[Current Column]),"MMMM\'yy","en"))