Forum Discussion
Changing date format to have short month name
Hi, I have this start of week column in my calendar
I want to create another column that would show start of week from this format in the image to this "14 Oct" I know there is option to change date formating in column
But the problem with this is that it gives month name in full where I want only short versions that only show first 3 caracter of the month like this
I tried to use this mcode solution to solve my problem but it did not work.
Date.ToText(#date([#"Start of Week"]),[Format="dd-mmm", Culture="en-UK"])
And it gave me this error instead
I am not really good with mcode so I am not sure on how to do it.
Justas4478 Hi! Try with:
= Table.TransformColumns(#PREVIOUS STEP, {{"Start of Week", each Date.ToText(_, "dd MMM"), type text}})
If it's ok, please accept my answer as solution!
BBF
6 Replies
- BeaBF
Super User
Justas4478 Hi! Try with:
= Table.TransformColumns(#PREVIOUS STEP, {{"Start of Week", each Date.ToText(_, "dd MMM"), type text}})
If it's ok, please accept my answer as solution!
BBF
- Justas4478
Post Prodigy
BeaBF It worked.
But when I tried to do sorty by column by Start of week.I got this error message
I think it has something to do with no year being in new column that I created.
I think some sorting column needs to be created.- BeaBF
Super User
Justas4478 you can just order the column in the power query, so it will mantain that order, code:
= Table.Sort(Custom1, {{"Start of Week", Order.Ascending}})
or you can create an index in DAX like:
UniqueIndex =RANKX(VALUES('Table'[Formatted Start of Week]),'Table'[Formatted Start of Week],,ASC,Dense)and use this column to sort the new one.BBF
- Omid_Motamedise
Super User
Add a new column by rewriteing the formula as follow
Date.ToText([#"Start of Week"]),[Format="dd-mmm", Culture="en-UK"])