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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
alopez802
New Member

How can I turn this column into a date type with a mm-yyyy format on power query?

I want to turn this column into a date type in power query but keep the month-year format. How can I achieve this on power query?

 

alopez802_0-1674773037019.png

 

5 REPLIES 5
ronrsnfld
Super User
Super User

You cannot. If you want the date displayed like that in the Power Query UI, you will have to set the data type to text and use a formula like: 

Table.TransformColumns(#"Previous Step",{"Column Name", each Date.ToText(_,"MM-yyyy"), type text})

 

Unlike Excel (or Power BI), Power Query does not have a separate formatting option for data.

I tried implementing your idea. In the step prior I made PGP Match a text type and then in the following step I implemented your step but got the result seen in the picture below. What did I do wrong?

 

alopez802_1-1674837381021.png

 

 

alopez802_3-1674838701462.png

 

 

Maybe I am misunderstanding you.

If you already have the column PGP Match as text, there's no need to change it into anything. As I wrote, you cannot change it into a date and have it display as `MM-yyyy` in the Power Query editor.

 

My solution is a method of generating PGP Match from a column that already has a Date.

Okay that makes sense. I misunderstood you the first time. Thank you.

nickvanmaele
Advocate II
Advocate II

In Power Query, when you turn text string "11-2022" into a date, it will add a day which is the first date of the month. Without a day being specified, it is not a date. Hence, here is no real date which is called "11-2022". 

 

It seems that you are looking for a display solution. 

In Power Query, you could keep date 2022-11-01 (or 01/11/2022 or 11/01/2022 or whatever your local date format is). In Power BI or Excel, you can change the display format for that particular column to "MM-YYYY"

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors