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?
In Dax, if you column type is 'Date', you can create a calculated column to extract the month. In PQ ,if your column type is 'Date', you can use the option 'Date'->'Month'->'Name of Month' to create a custom column.
Steps as per above illustrations: Fire up Power BI Desktop > edit query > Select your date table > select the date column > Add Column tab > Date button > Month > Month (again) > Select the Home tab > Closed and Apply.
You can use:
MonthName = FORMAT(DATE(1, [Num], 1), "MMM")
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With