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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Bokchoy
Helper II
Helper II

View Original SQL statement on Power BI desktop

Hi everyone,

 

I have a dataset constructed with a SQL statement. I can't seem to find the original SQL statement in query editor, anyone knows where I can find that.

Thanks

1 ACCEPTED SOLUTION

Hi, @Bokchoy 

According to your description, your dataset is created by SQL statement, which means that you have placed some SQL statement here, right?

v-robertq-msft_0-1615887746540.png

 

If so, I guess that is the reason why your “native query” option is greyed out.

Power Query cannot fold if you do that. If you want to do your own SQL plus have PQ fold more stuff, you need to create a view on your server and connect to that, or create ALL transformations in Power Query.

What’s more, one step in your query disabled “view native query”, the rest also can’t support it anymore. You can refer to this document to learn the reasons why query folding is disabled:

https://docs.microsoft.com/en-us/power-query/power-query-folding

 

Best Regards,

Community Support Team _Robert Qin

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
Anonymous
Not applicable

Here is the answer to this question.  Perhaps someone will find this information useful.  To view the original SQL query passed into the report.

 

1.)  Right click your query/fields on the right fields pane. Select edit query.

meeoun_0-1653067099092.png

2.) In the Power Query Editor window that opens.  Select the query you want to view.  Then select the gear icon of the Source under applied steps

3.) View the original query

meeoun_0-1653067302193.png

 

 

 

Anonymous
Not applicable

Im so confused as to why there are so many responses narrating what and how to use query folding.  That was not the question.  The question is to view the original SQL statement.  I have a report that uses a SQL statement, and I would like to view it to see its operations.

amitchandak
Super User
Super User

@Bokchoy , In power query, Right click on the table, open advance editor. You should see SQL there

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

The advanced query only shows me the applied steps that are used to transform the table. I'm looking for the native SQL query statement that was used to construct the table before its loaded into BI

Also when I right-click on the last applied step, the native query option is greyed out.

Hi, @Bokchoy 

According to your description, your dataset is created by SQL statement, which means that you have placed some SQL statement here, right?

v-robertq-msft_0-1615887746540.png

 

If so, I guess that is the reason why your “native query” option is greyed out.

Power Query cannot fold if you do that. If you want to do your own SQL plus have PQ fold more stuff, you need to create a view on your server and connect to that, or create ALL transformations in Power Query.

What’s more, one step in your query disabled “view native query”, the rest also can’t support it anymore. You can refer to this document to learn the reasons why query folding is disabled:

https://docs.microsoft.com/en-us/power-query/power-query-folding

 

Best Regards,

Community Support Team _Robert Qin

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

Anonymous
Not applicable

Where did he ask about query folding?  He just wants to see the original SQL query.  As do I.  I was given a report from someone else who used those options.

CNENFRNL
Community Champion
Community Champion

@Bokchoy , query folding, literally means PBI pushes as much workload of query as possible to the database side, isn't 100% guaranteed at the PBI side; when a query contains some functions without a SQL equivalent, query folding doesn't happen.

 

You might try to right click on preceding applied steps to see if there're any native query options available.

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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