How to Convert Month Number to Month Name in Power BI?

In this Power BI tutorial, we will learn how to convert month numbers to month names in Power BI.

We will also see how to get the month name from the date and how to convert the month number to the month name in the Power Query editor.

Convert Month Number to Month Name in Power BI

Let’s say you’re analyzing sales data in Power BI. You have a dataset with a column that contains the month number (1 for January, 2 for February, and so on), but you want to display the month names (January, February, etc.) in your reports instead.

Here, I have a SharePoint list (Monthly Sales Data) that contains below columns:

change months number to month name power bi

Now follow the below steps:

1. Load the SharePoint link above into your Power BI Desktop, and then you can see the data in the data pane.

how to change month number to month name in power bi

2. Here, I created two visuals. One is a slicer visual that displays only the month numbers, and the other is a column chart that shows sales organized by month numbers.

convert month number to month name power bi

3. Go to the Table view, then under the Table tools, click the New column.

how to change month number to name in power bi

4. In the formula bar, enter the following formula, then click the commit button.

MonthName = FORMAT(DATE(1, [Month Number], 1), "MMMM")

Where:

  • MonthName = Name of the measure where the month name is stored.
  • FORMAT() = This function is used to format a given value according to a specified format.
  • DATE(1, [Month Number], 1) = This function creates a date using the year 1, the provided month number, and day 1.
  • “MMMM” = This is a format string used with the FORMAT function to display the full name of the month from a given date.
month number to month name power bi

5. Then, you can see a new column added in the Table view.

power bi change month number to name

6. In the report view, change the slicer from displaying month numbers to displaying month names. Also, adjust the column chart to show sales by month names.

how to get month name from month number in power bi

This way, you can convert the month number to the month name in Power BI.

See also  How to Convert Decimal to Text in Power BI

Power BI Get Month Name From Date

Now, in the above SharePoint list, I add one more column, i.e., the date column.

change months number to month name power bi

Now we see how to get the month name from the date. Follow the below steps:

Here, I load the data again, this time removing the month number column and adding the date column.

power bi convert date to month name

Under the Modeling tab, click New column.

power bi convert date to name

In the formula bar, put the formula below. Then click the Commit button.

Month Name = FORMAT('Monthly Sales Data (2)'[Date],"MMMM")
power bi month name from date

Next, navigate to the table view, where you’ll notice that the month name column has been generated from the date column.

how to get month name from date in power bi

This way, you can extract the month name from the date in Power BI.

Power Query Month Number to Name

Now, we see how to convert the month number to the month name in the Power Query editor.

Here, I have two columns in Power Query. One column is the month number and sales.

how to get month number from month name in power query

Then, in the Power Query Editor, click Custom Column under Add Column.

month number to month name in power query

After that, the Custom Column window will open. Here, name the new column ‘Month Name’ and paste the formula into the Custom column formula box. Then, click OK.

Date.MonthName(#date(2024, [Month Number], 1))

Where:

  • #date(2024, [Month Number], 1) = This part creates a date using the year 2024, the month number from your dataset (represented by [Month Number]), and the day 1. So, if your dataset has a month number of 1, it will create the date January 1, 2040.
  • Date.MonthName() = This function takes a date as input and returns the name of the month associated with that date. So, if the date is January 1, 2024, it will return to “January.”
how to extract month names from number in Power query

Then, you can see a new column added in the Power Query Editor.

Power Query Month Number to Name

You can get the month name from the month number in Power Query.

See also  Create a Power BI Pie Chart | Power BI Pie Chart Multiple Values

I hope this tutorial provided you with all the necessary information. In this tutorial, we learned how to convert month numbers to month names in Power BI, how to extract the month name from a date, and how to perform the conversion from month number to month name in the Power Query editor.

You may also like the following tutorials:

>