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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to extract Month and Year from column in PowerBI powerquery

I have a column that looks like (A) and I want it to look like (B). How can I extract only the month and the year of each item in column A so that it can be a custom column like B?


A:

01/01/2020 12:00:00 AM

01/02/2020 12:00:00 AM

01/03/2020 12:00:00 AM

01/04/2020 12:00:00 AM

 

B:

01/2020

01/2020

01/2020

01/2020

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could try the following codes, it will return text type values.

= Table.AddColumn(#"Changed Type", "Custom", each 
   (if 
       Date.Month([Column1])<10
    then 
       "0" & Number.ToText(Date.Month([Column1]))
    else 
       Number.ToText(Date.Month([Column1])))
   &"/"&
   Number.ToText(Date.Year([Column1])))

 

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

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could try the following codes, it will return text type values.

= Table.AddColumn(#"Changed Type", "Custom", each 
   (if 
       Date.Month([Column1])<10
    then 
       "0" & Number.ToText(Date.Month([Column1]))
    else 
       Number.ToText(Date.Month([Column1])))
   &"/"&
   Number.ToText(Date.Year([Column1])))

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
AlB
Community Champion
Community Champion

Hi @Anonymous 

In Power Query you can either:

a) Create a custom column  with the code

      = [Column A]

   and then convert the type to Date (instead of the DateTime it now is

 

b) Create a custom column  with the code

      = Date.StartOfDay( [Column A] )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.