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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
dadelta50
Regular Visitor

month name to number

I have a file with 2 columns - Month, Year.  The month column is the text name for the month.  I would like to create a custom column that will create a date using the month & year columns and the day will be the last day of the month.

EXAMPLE of current file:

MONTH   YEAR

October   2010

I would like this to read 10/31/2010 in the new column.

Any help is greatly appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If you want to try DAX, you can create two columns to get the values

 

Date_Start = DATEVALUE('Tran'[Year]&"/"&'Tran'[Month]&"/"&"1")
Date_End = EOMONTH('Tran'[Date_Start],0)

Remember to change the data type to Date

2018-09-14_17-21-07.png

 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

If you want to try DAX, you can create two columns to get the values

 

Date_Start = DATEVALUE('Tran'[Year]&"/"&'Tran'[Month]&"/"&"1")
Date_End = EOMONTH('Tran'[Date_Start],0)

Remember to change the data type to Date

2018-09-14_17-21-07.png

 

 

 

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @dadelta50,

 

By my tests, the M query of ImkeF should solve your problem.

 

If you have solved your problem, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ImkeF
Super User
Super User

Create a new column that returns a text string with a full date expression with this formula:

 

"1."&[Month] &"."&Text.From([Year])

Then just convert this column to date.

 

If you want to retrieve the last date within the month, you can instead use this formula:

 

Date.EndOfMonth( Date.From( "1." & [Month] & "." & Text.From([Year]))))

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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