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
PrakashGupta
New Member

CONVERT(VARCHAR(10), Date, 20) is creating issues in direct query option while converting date in a

Hi All,
I am getting an error "This query contains transaformation that cannot be used for a live connection". I am using CONVERT(VARCHAR(10), Date, 20) in my query and using DirectQuery option instead of import.

 

Also if you can add some link how to use query in porwer BI that will be useful.

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

@PrakashGupta@hugoberry I got the information that DirectQuery works is by taking the user query and putting it into a subselect. In order for this to work, it needs to be able to reference columns in the user query by name. Duplicate names or names that are missing would prevent that from working. So this is effectively by design.

 

In your scenario, please specify a alias for that convert() results in T-SQL query as suggested in my first post.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

7 REPLIES 7
v-qiuyu-msft
Community Support
Community Support

@PrakashGupta@hugoberry I got the information that DirectQuery works is by taking the user query and putting it into a subselect. In order for this to work, it needs to be able to reference columns in the user query by name. Duplicate names or names that are missing would prevent that from working. So this is effectively by design.

 

In your scenario, please specify a alias for that convert() results in T-SQL query as suggested in my first post.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-qiuyu-msft
Community Support
Community Support

Hi @PrakashGupta,

 

Based on my tested in desktop version 2.45.4704.442 with DirectQuery mode, the T-SQL query below can works fine.

 

select CONVERT(VARCHAR(10), DateCol, 20) Col1
from [dbo].[DateVal]

 

In your scenario, I guess the issue my not related to Convert() function itself. The error message indicates there might have some action is not supported in DirectQuery mode. Please review the Limitations of DirectQuery . 

 

Would you please share the T-SQL query you used in desktop? Except this query, is there any other queries or transform actions performed in desktop?

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

As mentioned in my reply, you can replicate the issue if you don't give an alias to CONVERT call

@hugoberry Thanks for your prompt. Smiley Happy

 

@PrakashGupta I already sent a email to consult this issue internally, will update to you if I get any feedback.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hugoberry
Responsive Resident
Responsive Resident

Just tested your query. Indeed you get the problem if you don't specify a name for the column. Give an alias to convert... call either with AS or with [date_converted]=convert ... construct
hugoberry
Responsive Resident
Responsive Resident

Have you tried doing the date conversion in Power Query or data model instead?
Greg_Deckler
Super User
Super User

When you say in your query, you are referring to SQL, correct?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors