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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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