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
kimlien3006
Helper II
Helper II

How to transform period format ( JUL 2020) to format "2020007"?

Hi everybody, 

 

I hope you can help me to solve this issue. I've tried several ways but did not work. 

So I have a Period table with format: JAN 2020, FEB 2020, .... However, I would like to have this column with format: 2020001 for JAN 2020, 2020002 for FEB 2020. 

 

Any idea will be appreciated. 

 

Thank you so much! 

Best regards, 

Lien

1 ACCEPTED SOLUTION

@kimlien3006 

 

Please see complete formula. Make sure though the field is text and not date format

New_Date =
RIGHT(Table[DateToConvert],4) &
SWITCH ( LEFT(Table[DateToConvert],3), "JAN", "01", "FEB", "02", "MAR", "03", "APR", "04", "MAY", "05", "JUN", "06", "JUL", "07", "AUG", "08", "SEP", "09", "OCT", "10", "NOV", "11", "DEC", "12" )

View solution in original post

6 REPLIES 6
themistoklis
Community Champion
Community Champion

@kimlien3006 

 

Try the following formula if the field is text and not date

 

 

New_Date = 
RIGHT(Table[DateToConvert],4) & SWITCH ( LEFT(Table[DateToConvert],3), "JAN", "01", "FEB", "02", "MAR", "03", "APR", "04" )

 

 

Thanks @themistoklis  for the quick solution. However, I have data for the whole year. It seems your formula works for 4 months only? 

@kimlien3006 

 

Please see complete formula. Make sure though the field is text and not date format

New_Date =
RIGHT(Table[DateToConvert],4) &
SWITCH ( LEFT(Table[DateToConvert],3), "JAN", "01", "FEB", "02", "MAR", "03", "APR", "04", "MAY", "05", "JUN", "06", "JUL", "07", "AUG", "08", "SEP", "09", "OCT", "10", "NOV", "11", "DEC", "12" )

amitchandak
Super User
Super User

@kimlien3006 , Create a new column like this

date = "01 " & [Month year]  // Change data type to date

 

Now a new column

output = format([date],"YYYYMM")

or

output = format([date],"YYYY0MM")

Thanks @amitchandak  for the quick solution. I tried and the output column does not work. Do you have ideas how I could do it wrong. 

 

Annotation 2021-01-13 154542.jpg

@kimlien3006 

are you able to switch the Text column to Date?

1.png

if it works, then you can create a new column.

Column = year('Table'[Column1])*100+month('Table'[Column1])

2.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.