How to get month name from month number in Power BI?
Asked Answered
W

6

21

I have Year number and Month Number in my data. How using DAX can I get the month name out of month number?

In SSRS its very easy. But how to achieve that using DAX?

enter image description here

enter image description here

Whelm answered 22/3, 2017 at 23:33 Comment(4)
This is the first google response: daxtips.wordpress.com/2012/01/18/…. It says use the FORMAT function. Does this work for you?Skull
You can get the month name from the date using the following formula: FORMAT([Date], "MMM")Vanderbilt
I checked all responses. But I dont have date, I have number. So I need simply pass the number and return month name.Whelm
And of course I can get a date and get a month name from the source, but I'm just curious how would it be without the date. Learning process.Whelm
E
55

You can use:

MonthName = FORMAT(DATE(1, [Num], 1), "MMM")

Result:

result

Nothing fancy, simply a reconstruction of a fake date from the month number provided, and reformat it with the FORMAT function.

Of course as an alternative you can go the old-fashioned way and write a SWITCH statement and hard-coded for the 12 months. It's up to you.

Ecumenicism answered 23/3, 2017 at 1:57 Comment(2)
To get the full name of the month you can use "MMMM" instead of "MMM" as as the format stringOram
I am getting format is not a function. Can anyone assist?Vesica
T
5

You can try this too:

Month name = FORMAT('Table'[date_column], "MMM")

If you use single quotes in 'MMM', it doesn't work. Ensure to use ""

Tarpaulin answered 26/1, 2021 at 13:8 Comment(0)
L
0

u can use the Transform Value after you duplicate the Date Column and change the Day to Day Name.

Lauranlaurance answered 9/2, 2024 at 10:31 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Gorged
C
0

If Format() function is not working you can the "SWITCH" function to map MonthNumber to MonthName.

MonthName = SWITCH(
    TRUE(),
    [MonthNumber] = 1, "January",
    [MonthNumber] = 2, "February",
    [MonthNumber] = 3, "March",
    [MonthNumber] = 4, "April",
    [MonthNumber] = 5, "May",
    [MonthNumber] = 6, "June",
    [MonthNumber] = 7, "July",
    [MonthNumber] = 8, "August",
    [MonthNumber] = 9, "September",
    [MonthNumber] = 10, "October",
    [MonthNumber] = 11, "November",
    [MonthNumber] = 12, "December"
)

This formula checks the value of MonthNumber and returns the corresponding month name.

Cadman answered 22/5, 2024 at 13:9 Comment(0)
H
0

You can use FORMAT function to achieve this goal. = FORMAT('Tablename'[MonthNumber], "MMM") it will return the name of the month, e.g. July will be Jul, August will be Aug.

Hectic answered 24/7, 2024 at 1:28 Comment(0)
E
-1

By Use of Switch DAX function MonthName = switch(True(), MonthID = 1, "jan",MonthID = 2, "Feb",MonthID = 3, "March",MonthID = 4, "April",MonthID = 5, "May",MonthID = 6, "June",MonthID = 7, "july",MonthID = 8, "Aug",MonthID = 9, "Sept",MonthID = 10, "Oct",MonthID = 11, "Nov",MonthID = 12, "Dec" )

Edroi answered 27/10, 2022 at 11:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.