Skip to main content

Power BI

Completed

Power Query, convert date fields to monthname, weekdayname, quartername

Vote (67) Share
Terje Fjeldstad's profile image

Terje Fjeldstad on 08 May 2015 00:21:57

When using power Query to add columns based on A date field, it would be Nice to also be able to convert to month name, not just month number. Example; 31.01.2012 should have built-in function to set december or dec....monday or mon. Till now, we can only get numeric values.

Administrator on 02 Jul 2016 00:11:43

I'm glad to report that this transformation is now available in the June Update of Power BI Desktop: https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-june-update/ Extract Week Day and Month Name from a DateTime column Another very common customer request has been to provide a built-in transformation to extract the WeekDay or Month names from a given Date/Time column. We’ve made this available from the Query Editor ribbon (either via Transform to modify an existing column, or via Add Column to insert a new one). These two options can be found under “Date -> Day -> Name of Day” and “Date -> Month -> Name of Month”, respectively. Note that the Day/Month names are localized according to the Locale setting for your Power BI Desktop file (available under File -> Options -> Current File -> Regional Settings).

Comments (23)
Terje Fjeldstad's profile image Profile Picture

8e719df0 4260-4d32-82fb-8e73ea224705 on 05 Jul 2020 22:20:43

RE: Power Query, convert date fields to monthname, weekdayname, quartername

'Adding the equivalent TEXT function in Excel would be even better:
=TEXT(A1,"mmmm")
Gives
A1: 1
B2: "January"

Terje Fjeldstad's profile image Profile Picture

5c53f0ed 87eb-450e-b9ec-cc7601b8f3db on 05 Jul 2020 22:19:58

RE: Power Query, convert date fields to monthname, weekdayname, quartername

When you extract month from a date, it'd be great if it can extract it in "January, February" etc, rather than just the number.

Terje Fjeldstad's profile image Profile Picture

ec83dcb7 6fa5-4309-9fb1-966a55cffdc3 on 05 Jul 2020 22:14:55

RE: Power Query, convert date fields to monthname, weekdayname, quartername

It is very bad. we need option to order the date. my requirement is order the data based on month.

Terje Fjeldstad's profile image Profile Picture

19c0172d d505-4c17-8940-b911dc539f5f on 05 Jul 2020 22:14:28

RE: Power Query, convert date fields to monthname, weekdayname, quartername

Agree - Power BI's default date and time formatting is actually worse and offers fewer options than Excel 2007... and surely must be a drain on memory as you have to do a lot of data shaping just to get your time dimensions into shape - obviously there's the time series date hierarchy which is useful, but more often than not you want to plot / filter by specific names - end users like broad strokes.

Terje Fjeldstad's profile image Profile Picture

7d561761 c7f5-4f41-b3a8-fe41ff44d620 on 05 Jul 2020 22:12:32

RE: Power Query, convert date fields to monthname, weekdayname, quartername

Add a column =wekday([date])
Create a table (1..7)-(sun...sat)
Create relationship

Terje Fjeldstad's profile image Profile Picture

5be9cd56 2117-4e5b-ba0a-ca398237d742 on 05 Jul 2020 22:09:54

RE: Power Query, convert date fields to monthname, weekdayname, quartername

It is not working, with Format function. I have pulled the data from SharePoint. While trying to get the month name from Created field. For July it gives the month name as January while using the Format function.

Terje Fjeldstad's profile image Profile Picture

98f0fa0e f67d-4e52-94a7-470dc9351923 on 05 Jul 2020 22:09:09

RE: Power Query, convert date fields to monthname, weekdayname, quartername

If you do =FORMAT([date],"MMM")
how do you prevent Power BI visualizations from screwing up the sort?

Terje Fjeldstad's profile image Profile Picture

c3509cca 70fc-4f3e-b9f0-9681162e1609 on 05 Jul 2020 22:08:31

RE: Power Query, convert date fields to monthname, weekdayname, quartername

This is essential

The format date is not suitable for the reason given

Terje Fjeldstad's profile image Profile Picture

ee57373a f7b5-435c-9f17-e4d2b203264a on 05 Jul 2020 22:08:00

RE: Power Query, convert date fields to monthname, weekdayname, quartername

You can use the formula =FORMAT([date],"MMM") that Luis suggested then sort it by =Month([date]). To sort it by a separate column you can use the "Sort By Column" in the data tab.

Terje Fjeldstad's profile image Profile Picture

e6c828a0 fa08-4a31-a4c8-190b4b8fba7c on 05 Jul 2020 22:05:50

RE: Power Query, convert date fields to monthname, weekdayname, quartername

'@dhoff can you please help where to add this formula