20

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

Serdia
  • 4,242
  • 22
  • 86
  • 159
  • This is the first google response: https://daxtips.wordpress.com/2012/01/18/get-month-name-from-a-date-field/. It says use the `FORMAT` function. Does this work for you? – Nick.Mc Mar 22 '17 at 23:54
  • You can get the month name from the date using the following formula: FORMAT([Date], "MMM") – MayowaO Mar 23 '17 at 00:01
  • I checked all responses. But I dont have date, I have number. So I need simply pass the number and return month name. – Serdia Mar 23 '17 at 01:16
  • 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. – Serdia Mar 23 '17 at 01:18

3 Answers3

53

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.

Foxan Ng
  • 6,883
  • 4
  • 34
  • 41
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 ""

Job Kavoya
  • 91
  • 1
  • 5
0

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" )