Convert UTC date format into local time format in Power BI

Most of the times while importing date data from different sources the format is in UTC time format. For the accurate reporting and visuals in Power BI dashboards we need to have this in local time format. In this post we will see how you can convert the UTC date data into local time format.
For example if we have the following Opportunity data from Dynamics CRM, there is a column called EstimatedCloseDate which is in the UTC format. We want to convert this date into our local time zone format.

Estimated Close Date Oppurtunity Data

First of all lets rename this column to EstimatedCloseDateUTC. Then go to the “Transform” tab in the ribbon and change its datatype to Date/Time/TimeZone. Next we can use the Add Column transformation to insert new column in the Query. To do this, we can go to the Add Column tab in the ribbon and click on the Date->DateOnly menu item. This will add a second column with the date as shown below.

new date column

When you add this transformation the following M code was generated for this step.

= Table.AddColumn(#”Changed Type”, “Date”, each DateTime.Date([EstimatedCloseDateUTC]), type date)

In this M code we need to manually replace the DateTime.Date function with the DateTimeZone.ToLocal function. Next the data type of this new column can set to Date Only. When this is done we get the following result

final date

To finish we can remove the EstimatedCloseDateUTC column and rename Date to EstimatedCloseDate.

final result in date

And thats it , you have successfully transformed a UTC time format date to your local time zone format.



6 Comments

  • Will this work for Power Bi desktop version only, or for Power BI online too. I mean how the DateTimeZone.ToLocal function will convert the UTC time to my machine’s local time if it will be invoked from inside the BI online?

    Sorry if the question doesn’t make sense, as I am not much aware of the Power BI yet.

  • […] Also note the EstimatedCloseDate is in UTC format. We need to convert it into local time format. There is a separate post on how you can convert it into local time zone . […]

  • Aarthi

    Would it convert a “mm/dd/yyyy” format date as well to local format.
    The date displays as “dd/mm/yyyy” in a excel sheet. If I use a .csv source – then my date is jeopardised.

  • Atul Tandon

    I am using Power BI Desktop and These steps are not converting the date to local , it does show number of hours to be added if I change the type to time zone, However it does not actually add those hours to the date to make it local

  • Hi there, just became alert to your blog through Google, and found that it is truly informative. I’m gonna watch out for brussels. I will be grateful if you continue this in future. Lots of people will be benefited from your writing. Cheers!

Leave a Reply

*

code