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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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