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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Convert numbers to month

Hi everybody,

 

I have a column with months dates in numbers. I want to convert it to text and keep the monthly order as Jun, Feb, Mar, Apr, etc..

 

I tried several trick like grouping or entering a new table to edit relationships, however in the graph the months are sorted alphabetically. I also tried the formula Months = text('date'[Month],"MMM") but still doesn't work.

 

Any help?

 

Cheers,

Andrea

1 ACCEPTED SOLUTION

Hi @Anonymous,


The month column is RS month. I need to convert thos numbers in text as Jan, Feb, Mar, etc. but keeping the monthly order when showed in a graph.


In this scenario, you can use the formula below to create a new calculate column to convert the numbers in text as Jan, Feb, Mar, etc. Smiley Happy

Short Month =
SWITCH (
    Table1[RS Month],
    1, "Jan",
    2, "Feb",
    3, "Mar",
    4, "Apr",
    5, "May",
    6, "Jun",
    7, "Jul",
    8, "Aug",
    9, "Sep",
    10, "Oct",
    11, "Nov",
    12, "Dec",
    BLANK ()
)

To keep the monthly order for the "Short Month" column, you can use the 'Sort by Column' option under Modeling tab.

  1. Select "Short Month" column.
  2. Click 'Sort by Column' option under Modeling tab.
  3. Select "RS Month" column.

c1.PNGr1.PNG

Regards

View solution in original post

9 REPLIES 9
DlyGMCT
New Member

Not sure if this will work for you but seems most of the solutions here are overly complex.

 

try this formula

format(date(1,'date'[Month],1),"MMM")

vanessafvg
Super User
Super User

matt mattson has this blog post

https://www.mattmasson.com/2014/02/creating-a-date-dimension-with-a-power-query-script/

 

use some of the logic here and do it in power query , you might have to convert then convert again.

 

and then in modelling in power bi set your name column to sort by the number.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




spuder
Resolver IV
Resolver IV

Hi @Anonymous

 

use format instead of text...

 

Month short = FORMAT('date'[Month],"MMM")
Anonymous
Not applicable

Hi @spuder,

 

thanks for your help. I already tried this but look at the results.. It converts 1 as Dec and all the others as Jan.

 

2017-05-22 14_52_00-Sales Overview - Copy - Power BI Desktop.png

@Anonymous

 

Could you show me the column where you'd like to extract the Month short?

 

Anonymous
Not applicable

@spuder

The month column is RS month. I need to convert thos numbers in text as Jan, Feb, Mar, etc. but keeping the monthly order when showed in a graph.

 

@vanessafvg

can access the page, company firewall block it

Hi @Anonymous,


The month column is RS month. I need to convert thos numbers in text as Jan, Feb, Mar, etc. but keeping the monthly order when showed in a graph.


In this scenario, you can use the formula below to create a new calculate column to convert the numbers in text as Jan, Feb, Mar, etc. Smiley Happy

Short Month =
SWITCH (
    Table1[RS Month],
    1, "Jan",
    2, "Feb",
    3, "Mar",
    4, "Apr",
    5, "May",
    6, "Jun",
    7, "Jul",
    8, "Aug",
    9, "Sep",
    10, "Oct",
    11, "Nov",
    12, "Dec",
    BLANK ()
)

To keep the monthly order for the "Short Month" column, you can use the 'Sort by Column' option under Modeling tab.

  1. Select "Short Month" column.
  2. Click 'Sort by Column' option under Modeling tab.
  3. Select "RS Month" column.

c1.PNGr1.PNG

Regards

Anonymous
Not applicable

Hi @v-ljerr-msft,

 

it works perfectly thanks!

paste this into a blank power query

 

let CreateDateTable = (StartDate as date, EndDate as date, optional Culture as nullable text) as table =>
let
DayCount = Duration.Days(Duration.From(EndDate - StartDate)),
Source = List.Dates(StartDate,DayCount,#duration(1,0,0,0)),
TableFromList = Table.FromList(Source, Splitter.SplitByNothing()),
ChangedType = Table.TransformColumnTypes(TableFromList,{{"Column1", type date}}),
RenamedColumns = Table.RenameColumns(ChangedType,{{"Column1", "Date"}}),
InsertYear = Table.AddColumn(RenamedColumns, "Year", each Date.Year([Date])),
InsertQuarter = Table.AddColumn(InsertYear, "QuarterOfYear", each Date.QuarterOfYear([Date])),
InsertMonth = Table.AddColumn(InsertQuarter, "MonthOfYear", each Date.Month([Date])),
InsertDay = Table.AddColumn(InsertMonth, "DayOfMonth", each Date.Day([Date])),
InsertDayInt = Table.AddColumn(InsertDay, "DateInt", each [Year] * 10000 + [MonthOfYear] * 100 + [DayOfMonth]),
InsertMonthName = Table.AddColumn(InsertDayInt, "MonthName", each Date.ToText([Date], "MMMM", Culture), type text),
InsertCalendarMonth = Table.AddColumn(InsertMonthName, "MonthInCalendar", each (try(Text.Range([MonthName],0,3)) otherwise [MonthName]) & " " & Number.ToText([Year])),
InsertCalendarQtr = Table.AddColumn(InsertCalendarMonth, "QuarterInCalendar", each "Q" & Number.ToText([QuarterOfYear]) & " " & Number.ToText([Year])),
InsertDayWeek = Table.AddColumn(InsertCalendarQtr, "DayInWeek", each Date.DayOfWeek([Date])),
InsertDayName = Table.AddColumn(InsertDayWeek, "DayOfWeekName", each Date.ToText([Date], "dddd", Culture), type text),
InsertWeekEnding = Table.AddColumn(InsertDayName, "WeekEnding", each Date.EndOfWeek([Date]), type date)
in
InsertWeekEnding
in
CreateDateTable





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Solution Authors
Top Kudoed Authors