Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Convert Datetimeoffset to Datetime in Directquery

Hey, this is a newbie question 🙂 My source data contains a datetimeoffset column and Im using directquery. After my data loads up, I can't create a new hierarchy as "YYYY" , "MM", "DD" . And I cant edit my data because its a directquery.. Datetime column contains UTC so, I cant create any report based on days or months.. How can I create a datetime column?

 

2 ACCEPTED SOLUTIONS
hnguy71
Memorable Member
Memorable Member

Hi @Anonymous 

Are you saying that you have the text UTC inside your transaction date? 
UTC.png
If it looks similar to this, you can transform the column and extract text before delimiter and then change it's type to datetime.
converted.png



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

By my test, the type of Datetimeoffset is shown as the type of Date/Time/Zone in Power Query. When apply and close the query, the column will show Date/Time automatically. I could create formulas to get  year, month and day.

  • Calculated columns

 

Year = YEAR(Table_4[Time])
Month = MONTH(Table_4[Time])
Year = YEAR('Table_4 (2)'[Time])
  • Measures

 

Year = YEAR(MAX('Table_4 (2)'[Time])) 
Month = MONTH(MAX('Table_4 (2)'[Time]))
Day = DAY(MAX('Table_4 (2)'[Time]))

111.PNG4.PNG

If it still don't work, can you please post a dummy file or screenshots? 

 

Best Regards,

Xue

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

Could you tell me if your problem has been solved? If it is, kindly mark the helpful answer as a solution if you feel that makes sense. Welcome to share your own solution. More people will benefit from here.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

By my test, the type of Datetimeoffset is shown as the type of Date/Time/Zone in Power Query. When apply and close the query, the column will show Date/Time automatically. I could create formulas to get  year, month and day.

  • Calculated columns

 

Year = YEAR(Table_4[Time])
Month = MONTH(Table_4[Time])
Year = YEAR('Table_4 (2)'[Time])
  • Measures

 

Year = YEAR(MAX('Table_4 (2)'[Time])) 
Month = MONTH(MAX('Table_4 (2)'[Time]))
Day = DAY(MAX('Table_4 (2)'[Time]))

111.PNG4.PNG

If it still don't work, can you please post a dummy file or screenshots? 

 

Best Regards,

Xue

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hnguy71
Memorable Member
Memorable Member

Hi @Anonymous 

Are you saying that you have the text UTC inside your transaction date? 
UTC.png
If it looks similar to this, you can transform the column and extract text before delimiter and then change it's type to datetime.
converted.png



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

yes, this (pic) is "Edit Data" mode and I want to use my date column without UTC because its not possible to create charts with datetimeoffset columns.. your solution is not supported in Directquery mode..

2.PNG

@Anonymous 
Okay I'm totally confused since your first picture shows that your Transaction Date column is a text type but in your last post it is a datetimezone type column which should be able to give you your date hierarchy. I can't recreate your issue but if you want to remove the timezone offset what you'll need to do is extract it via DAX using a calculated column with the formula below:

TransactionDate = PATHITEM(SUBSTITUTE([Transaction Date], " ", "|", 2), 1, TEXT)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Can you please give me instructions step by step? I started to use PowerBI this week and I dont really know how to do it 🙂 Thanks!

@Anonymous 
1. Under MODELING ribbon tab, choose NEW COLUMN

2. Inside the formula bar for the new column, replace the default formula with this:

TransactionDate = PATHITEM(SUBSTITUTE([Transaction Date], " ", "|", 2), 1, TEXT)

3. Under MODELING ribbon tab again, change DATA TYPE to DATE/TIME



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Getting error

 

@Anonymous 
Totally forgot that while in DirectQuery mode, the use of Parent-Child functions are disallowed. Is there a reason why you need to be in DirectQuery vs Import? In any case, try this instead:

TransactionDate = LEFT(SUBSTITUTE([Transaction Date], " ", "|", 2), SEARCH("|", SUBSTITUTE('[Transaction Date], " ", "|",2))-1)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.