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
xRTP
Helper V
Helper V

Convert Month text to date in Power M

Hello i have a month text come from sharepoint list so i need to convert it to date. I tried to convert it using DAX but im still having issues with the relationship i guess because my other 2 tables have date datatype while i just convert this table's month text to date.

 

xRTP_0-1674193974629.png

 

4 REPLIES 4
MahyarTF
Memorable Member
Memorable Member

Hi,

Use below code to create the datecolumn :

DateCol =
Var __MonthNumber = SWITCH(Sheet112[Month Name],"January", 1,"February",2,"March",3,"April",4,"May",5,"June"
                           ,6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)
return date(YEAR(TODAY()), __MonthNumber, "01")
Then change the datatype of the new record to Date and put your format on it :
MahyarTF_0-1674195387026.png

 

Appreciate your Kudos and please mark it as a solution if it helps 

Mahyartf
pratyashasamal
Super User
Super User

Hi @xRTP ,
You could use datevalue function for this .

For example Date =DATEVALUE([Year] + "/" + [Month] + "/" + 01)   or similiar.
Thanks ,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

 




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

Proud to be a Super User!





I dont have a year only month that was on text form

hi @xRTP ,
You could simple use a static value in place of year or you can make it dynamic by using TODAY() function 
For Example :-
Date =DATEVALUE(YEAR(TODAY())+ "/" + [Month] + "/" + 01)   or similiar.
Date =DATEVALUE(YEAR("January 2023")+ "/" + [Month] + "/" + 01)
Thanks ,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C





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

Proud to be a Super User!





Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.