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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
pardeepd84
Helper III
Helper III

datevalue from text to number

Hi,

 

I need to convert the months from text to a number, i have the names of the month in a column but need these to be shown as number.  I am trying to use datevalue to convert the month from January to 01/January/2019.  How could I combine the data from the column and change it to a number/date. 

 

I have tried the following formula but get an error message.

 

pardeepd84_0-1629934330904.png

 

2 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

hi @pardeepd84 

 

Try this measure:

Convert to date = DATEVALUE("01/"&FIRSTNONBLANK('Table'[Month Name],"")&"/2019")

 

the output will be as below:

VahidDM_0-1629936020188.png

 

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

Appreciate your Kudos VahidDM_1-1629936036200.png !!

View solution in original post

v-eqin-msft
Community Support
Community Support

Hi @pardeepd84 ,

 

Based on my test, you could use the following formula to create a Date column or a Month number column:

Date= DATEVALUE("01-"&[Month Name]&"-2019")
Month Number = MONTH( DATEVALUE("01-"&[Month Name]&"-2019") )

 And then change the Format as you expect:

Eyelyn9_1-1630289596146.png

 

Refer to:

DATEVALUE function (DAX) - DAX | Microsoft Docs

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @pardeepd84 ,

 

Based on my test, you could use the following formula to create a Date column or a Month number column:

Date= DATEVALUE("01-"&[Month Name]&"-2019")
Month Number = MONTH( DATEVALUE("01-"&[Month Name]&"-2019") )

 And then change the Format as you expect:

Eyelyn9_1-1630289596146.png

 

Refer to:

DATEVALUE function (DAX) - DAX | Microsoft Docs

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

Date = 1*("01/"&Data[Month Name]&"/2019")

Format this as a Date.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
DataZoe
Microsoft Employee
Microsoft Employee

@pardeepd84 You could try this:

MonthAsNum = (search(left('Table'[MonthName],3), "JanFebMarAprMayJunJulAugSepOctNovDec",1,-2)+2)/3

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

VahidDM
Super User
Super User

hi @pardeepd84 

 

Try this measure:

Convert to date = DATEVALUE("01/"&FIRSTNONBLANK('Table'[Month Name],"")&"/2019")

 

the output will be as below:

VahidDM_0-1629936020188.png

 

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

Appreciate your Kudos VahidDM_1-1629936036200.png !!

HI,

 

Hi I still get the same error message.  

 

@pardeepd84 

Can you share sample of your data in the table format here (not image), or share your PBI file?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.