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
Paulyeo11
Impactful Individual
Impactful Individual

How to convert date to year ?

Hi All

 

I have Raw data below :-

 

Date

12/2/2020

20/12/2019

 

My excepted result :-

Year,motn,Date

2020,2,12/2/2020

2019.12.2019

 

Hoep some one can advise me.

 

Paul Yeo

9 REPLIES 9
Anonymous
Not applicable

@Paulyeo11 @Pragati11 @Anonymous  @amitchandak 

You Have to create a new column .

Write below formula 

New Date = Format(table1[date], "YYYY.mm.dd")

This code is more efficiant  and let you modify your date as per your requirement .

You will get the desired result .

Give kudos if is it work for you .


Anonymous
Not applicable

@Paulyeo11 Duplicate the date column (twice) in Power Query editor and transform to Year, Month no.. As Power Query supports 2 columns to merge at once, first merge would be on Year and Month no. and next merge will be of resultant column (year,monthno.) with Date.

Please mind the sequence you select the columns to merge.

amitchandak
Super User
Super User

@Paulyeo11 ,

 

year = right([column],4)

 

Month =
var _pos = search("/",[column],,0)
return
mid([column],_pos+1,2)

 

new date =
var _pos = search("/",[column],,0)
return
date(right([column],4), mid([column],_pos+1,2), left([column],_pos-1))

Hi Amit

I get error msg :-

Paulyeo11_0-1601971807134.png

 

Pragati11
Super User
Super User

Hi @Paulyeo11 ,

 

You can create new columns for YEAR and MONTH using DAX as follows:

 

yearCol = YEAR(tablename[Date])

monthCol = MONTH(tablename[Date])

 

Replace tablename[Date] in the above DAX expressions with your table name and date column name.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Paulyeo11
Impactful Individual
Impactful Individual

Hi Miss ,  Can you share how to start DAX ?

Hi @Paulyeo11 ,

 

You don't have to start DAX. It's in Power BI only. Just see the GIF below on how you can create a dax calculation:

colCreation.gif

 

Check the following link to go through starting with DAX in Power BI:

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-quickstart-learn-dax-basics

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Paulyeo11
Impactful Individual
Impactful Individual

Hi Miss 

Thank you for sharing the link . Now more lady start to like data visulisation. it use to be for man only.

Paul Yeo

 

@Paulyeo11 That statement would have been inappropriate back in 1960, and it is very inappropriate today. I think you want to apologize to @Pragati11 .

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.