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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Krupar
Frequent Visitor

Power BI -How to get the report query (Full query) in sql format

Hi Team,

 

Currently we are migrating from Yellowfin to Power BI.The backend database is oracle

We are new to Power BI and for faster migration we need the entire Report query (Full query) in sql format to compare with the Old reports.

Pls let us know how to fetch the full report query

2 ACCEPTED SOLUTIONS
saud968
Super User
Super User

To fetch the full report query in SQL format from Power BI, you can follow these steps:

  1. Open the Report in Power BI Desktop:

    • Load your Power BI report in Power BI Desktop.
  2. Use Performance Analyzer:

    • Go to the “View” tab and click on “Performance Analyzer”.
    • Click on “Start Recording” and then refresh the visuals in your report.
    • Once the visuals are refreshed, you will see the queries listed in the Performance Analyzer pane.
  3. Copy the Query:

    • Expand the visual you are interested in and click on “Copy Query”.
    • This will copy the DAX query generated by the visual.
  4. Convert DAX to SQL:

    • Since Power BI primarily uses DAX (Data Analysis Expressions), you might need to convert the DAX query to SQL if your backend is Oracle. Tools like DAX Studio can help you analyze and convert DAX queries.
  5. Using DAX Studio:

    • Download and install DAX Studio.
    • Connect DAX Studio to your Power BI model.
    • Run the copied DAX query in DAX Studio to analyze and convert it to SQL.
  6. Direct Query Mode:

    • If your Power BI report is using Direct Query mode, you can directly see the SQL queries being sent to the Oracle database. This can be done by checking the query logs on your Oracle server.

By following these steps, you should be able to fetch the full report query and compare it with your old reports.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

View solution in original post

Anonymous
Not applicable

Hi @Krupar ,

 

Thanks saud968  for the quick reply. I have some other thoughts to add:

Here I made a test to connect to Oracle database using Direct Query in Power BI desktop. To see the query for Power BI desktop report, we can find the file named FlightRecorderCurrent.trc in the file path as below. And then use SQL server Profiler to open the file to get SQL query .

 

C:\Users\Username\Microsoft\Power BI Desktop Store App\AnalysisServicesWorkspaces\AnalysisServicesWorkspacexxxx\Data
 
As in the picture, we can find the SQL query easily.
vtangjiemsft_0-1729062690750.png

For the report in power Service, aiming to see the SQL query, we can change the setting of Microsoft.PowerBI.DataMovement.Pipeline.GatewayCore.dll.config file, Just change the EmitQueryTraces value from False to True. Please refer to the online document.Through this way we can get the SQL query like this:

vtangjiemsft_1-1729062712630.png

 

Best Regards,

Neeko Tang

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Krupar ,

 

Thanks saud968  for the quick reply. I have some other thoughts to add:

Here I made a test to connect to Oracle database using Direct Query in Power BI desktop. To see the query for Power BI desktop report, we can find the file named FlightRecorderCurrent.trc in the file path as below. And then use SQL server Profiler to open the file to get SQL query .

 

C:\Users\Username\Microsoft\Power BI Desktop Store App\AnalysisServicesWorkspaces\AnalysisServicesWorkspacexxxx\Data
 
As in the picture, we can find the SQL query easily.
vtangjiemsft_0-1729062690750.png

For the report in power Service, aiming to see the SQL query, we can change the setting of Microsoft.PowerBI.DataMovement.Pipeline.GatewayCore.dll.config file, Just change the EmitQueryTraces value from False to True. Please refer to the online document.Through this way we can get the SQL query like this:

vtangjiemsft_1-1729062712630.png

 

Best Regards,

Neeko Tang

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

Great I was not aware of this. This is helpful thanks for adding this. 

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

saud968
Super User
Super User

To fetch the full report query in SQL format from Power BI, you can follow these steps:

  1. Open the Report in Power BI Desktop:

    • Load your Power BI report in Power BI Desktop.
  2. Use Performance Analyzer:

    • Go to the “View” tab and click on “Performance Analyzer”.
    • Click on “Start Recording” and then refresh the visuals in your report.
    • Once the visuals are refreshed, you will see the queries listed in the Performance Analyzer pane.
  3. Copy the Query:

    • Expand the visual you are interested in and click on “Copy Query”.
    • This will copy the DAX query generated by the visual.
  4. Convert DAX to SQL:

    • Since Power BI primarily uses DAX (Data Analysis Expressions), you might need to convert the DAX query to SQL if your backend is Oracle. Tools like DAX Studio can help you analyze and convert DAX queries.
  5. Using DAX Studio:

    • Download and install DAX Studio.
    • Connect DAX Studio to your Power BI model.
    • Run the copied DAX query in DAX Studio to analyze and convert it to SQL.
  6. Direct Query Mode:

    • If your Power BI report is using Direct Query mode, you can directly see the SQL queries being sent to the Oracle database. This can be done by checking the query logs on your Oracle server.

By following these steps, you should be able to fetch the full report query and compare it with your old reports.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

Many Thanks @saud968 for the Prompt Response.

I executed the steps as per your given solution.I was able to get the DAX query and for the sql query conversion i used the DAX studio.

Below is the screeshot..Just want a confirmation whether this query will include all the filters and the formulas .Is it the correct way to check the query..Pls advice

Krupar_0-1729173051994.png

 

Thanks for ur help

 

Yes, this should have the filters but this is Dax format. You can also work with steps shared by @Anonymous . Another option is that the SQL query generated by Power Query, go to the “Advanced Editor” in the Power Query Editor. The M code in the Advanced Editor shows the transformations applied. While this is not SQL, it gives you an idea of the data shaping steps. For a more SQL-like query, you can use the “View Native Query” option (if available) by right-clicking on the last step in the “Applied Steps” pane. This shows the SQL query sent to the Oracle database.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

@Krupar If the suggestion works then please accept it as a solution

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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