cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Convert Text to Date in Direct Query mode

Hi, I'm using DirectQuery mode for my report. I have date fields which are of the data type Text.

 

I tried converting it into Date by changing the Data Type from Text to Date. It says "This step results in a query that is not supported in DirectQuery mode." I get the same error when I try to add a custom column (Month = Date.FromText([DateField])).

 

How do I get the month number, month name, and year from the text field? How do I convert the text field into a date field in DirectQuery mode? The existing solutions do not seem to work in DirectQuery mode.

 

Please help! Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Convert Text to Date in Direct Query mode

@poornapriya ,

 

While connecting to direct query mode you can use native query editor to transform your columns.

CONVERT(datetime, YourDatecolumn)

 

Capture.JPG

 

Don't forgrt to hit THUMBS UP and Accept this as a solution if it helps you!

Don't forget to give thumbs up and accept this as a solution if it helped you

View solution in original post

2 REPLIES 2
Highlighted
Super User II
Super User II

Re: Convert Text to Date in Direct Query mode

@poornapriya ,

 

While connecting to direct query mode you can use native query editor to transform your columns.

CONVERT(datetime, YourDatecolumn)

 

Capture.JPG

 

Don't forgrt to hit THUMBS UP and Accept this as a solution if it helps you!

Don't forget to give thumbs up and accept this as a solution if it helped you

View solution in original post

Highlighted
Frequent Visitor

Re: Convert Text to Date in Direct Query mode

@Tahreem24Thank you!

 

For others having the same issue,

Use the following SQL command while getting data for your report:

SELECT CONVERT(date, [DateSubmitted]) as [DateSubmitted]
,DATEPART("MONTH", [DateSubmitted]) as [Month]
,DATEPART("YEAR", [DateSubmitted]) as [Year]
,(DATEPART("WEEK", [DateSubmitted]) as [Week]
,'Q' + CAST(DATEPART("QUARTER", [DateSubmitted]) as varchar) as [Quarter]
FROM..

 

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors