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
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

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.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors