cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.

2 ACCEPTED SOLUTIONS
Super User

Try this measure:

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

the output will be as below:

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:

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.

6 REPLIES 6
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:

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.

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
Employee

@pardeepd84 You could try this:

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

Respectfully,
Zoe Douglas (DataZoe)

See my reports and blog at https://www.datazoepowerbi.com/

Super User

Try this measure:

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

the output will be as below:

Helper III

HI,

Hi I still get the same error message.

Super User

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

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors