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