Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Transform date into month and year format

Hi All,

 

i need to know, how Transform date into month and year format in excel query

 

rkrishnan_0-1601198173087.png

 

1 ACCEPTED SOLUTION

@Anonymous Do you want seperate column for Month and Year in your data, you can do this using below lines in power query

 

#"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([Date]), type text),
#"Inserted Year" = Table.AddColumn(#"Inserted Month Name", "Year", each Date.Year([Date]), Int64.Type)

 

Your output will be like below

negi007_0-1601207891540.png

 




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



Proud to be a Super User!


Follow me on linkedin

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi All, i need to know, how Transform date into month and year format in excel query i try this 1. Extract the Year into 1 column & Month Number into a second column, then Merge the columns together with a “-” as a separator then its come as Apr-2019 but remain as text format, while transform into pivot table as report, then the report comes in April-2019, August -2019, but i need April, May, June

@Anonymous Do you want seperate column for Month and Year in your data, you can do this using below lines in power query

 

#"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([Date]), type text),
#"Inserted Year" = Table.AddColumn(#"Inserted Month Name", "Year", each Date.Year([Date]), Int64.Type)

 

Your output will be like below

negi007_0-1601207891540.png

 




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



Proud to be a Super User!


Follow me on linkedin

@Anonymous 

Instead of creating those columns in Power Query, do it in the Data Model.

Go to your table, add a new column for Year Month Sorting:

 

YearMonthSort = YEAR([DATE]) * 100 + MONTH([DATE])

 


Add the Year Month column to use in visuals

 

Year Month = FORMAT([DATE],"MMM YYYY")

 

 

Now select the Year Month Column and got the Column Tools tab and sort by YearMonthSort column, Done

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 







 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors