I am trying to end up with a column that contains the month and year of a DateTime field.
I can find how to extract the month from a date or extract the year but I cannot find how to extract the month and year into one field.
Go to Solution.
= MONTH([date] & YEAR([date])
Or, the long way:
Proud to be a Datanaut!
And wrap the whole thing in VALUE() to cast back to a numeric type if you need:
= VALUE( MONTH( [Date] ) & YEAR( [Date] ) )
This works when you extract Year and Monthnumber like 20141, 20142,20143....201412...but if I want to get 2014 Jan, 2014 Feb, 2014 Mar and so...
this forumula works better when you extract monthnumber and yr, Any thoughts on that what I mentioned above.
Appreciated your support.
My DateKey looks like this 5/7/2007 12:00:00 AM and so on. How do I extract just the month and the year? I'd like to leave the original column alone and put the new date (month and year) into a new column. Any help is appreciated. Thanks!
Hope this helps.
yes, that worked. Thank you!
It my reply helped, please mark it as Answer.
I tried doing that but the data got sorted in descending order, meaning, whichever months had higher sales appeared first. I would like to sort the data by month.
Please help if this formula should be used as DAX or M code.
I tried using formula to create custom column (format "MM-YY) from existing date field (Date 2) in POWER BI desktop however seems it got set up as measure (see attached).
Power BI Super User, Greg Deckler, explains
Register by September 5 to save $200
Engage and empower students with Power BI!
Continue your learning in our online communities.