cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pap16 Frequent Visitor
Frequent Visitor

Get month and year from date

Hi,

 

I want to get the month and year in format January 2019 etc from my date column. I tried the below format but i get this error-

FORMAT ( 'TABLENAME'[Date], "MMMYY" )

Function 'FORMAT' is not allowed as part of calculated column DAX expressions on DirectQuery models.

 

I also tried concatenating the year and month column it works but i dont get the data sorted properly.

Please suggest Thanks

9 REPLIES 9
kcantor Super Contributor
Super Contributor

Re: Get month and year from date

@Pap16 

Try this slight variation:

=FORMAT(Data[Date],"MMM-YY")

Also, are you using a date table or a fact table with a date column?

In addition, check this thread for assistance as well.

https://community.powerbi.com/t5/Desktop/Transform-date-to-MM-YYYY/td-p/205311



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Pap16 Frequent Visitor
Frequent Visitor

Re: Get month and year from date

I am still getting same error with FORMAT. 

I have date column from fact table. The other link you shared it converts it into format 2017-1 but i want it to be 2017 January etc and also be able to sort based on this column value.

 

Or is it possible to create date hierarchy from this column. Right now i dont see option for that when i right click on that column.

Community Support Team
Community Support Team

Re: Get month and year from date

Hi @Pap16 

Create columns

year-month = FORMAT([Date],"yyyy mmmm")

sort by = FORMAT([Date],"yyyymm")

Select "year-month" column, then select "sort by column"->"sort by" column

5.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Pap16 Frequent Visitor
Frequent Visitor

Re: Get month and year from date

I am still having issues. I have attached screenshots how my column shows up. Its coming from Dimension table and i have shown data as well. Its datatype is date.example.png

sgsukumaran Member
Member

Re: Get month and year from date

@Pap16 - From your screenshots it appears that you are using direct query model. If so you cannot add columns at this time. You can only create measures. You are tryin to accomplish row context and the best way to do this is to add your logic to your model.

kcantor Super Contributor
Super Contributor

Re: Get month and year from date

@sgsukumaran  That is a good catch.  Kudos to you!



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Pap16 Frequent Visitor
Frequent Visitor

Re: Get month and year from date

Add it to Dimension table or create a measure? Could you help with this
Highlighted
sgsukumaran Member
Member

Re: Get month and year from date

I would add it to the Dimension table, redeploy and process.

Pap16 Frequent Visitor
Frequent Visitor

Re: Get month and year from date

I also have a column with info like 2019-01 ,2019-02 etc . I was thinking if i could convert it to 2019 January etc that could do it. Is that possible in this model?

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)