• Home
  • About Us
  • Contact Us
  • Privacy Policy
  • Special Offers
Business Intelligence Info
  • Business Intelligence
    • BI News and Info
    • Big Data
    • Mobile and Cloud
    • Self-Service BI
  • CRM
    • CRM News and Info
    • InfusionSoft
    • Microsoft Dynamics CRM
    • NetSuite
    • OnContact
    • Salesforce
    • Workbooks
  • Data Mining
    • Pentaho
    • Sisense
    • Tableau
    • TIBCO Spotfire
  • Data Warehousing
    • DWH News and Info
    • IBM DB2
    • Microsoft SQL Server
    • Oracle
    • Teradata
  • Predictive Analytics
    • FICO
    • KNIME
    • Mathematica
    • Matlab
    • Minitab
    • RapidMiner
    • Revolution
    • SAP
    • SAS/SPSS
  • Humor

Get the SQL Query used in DirectQuery mode

February 15, 2020   Self-Service BI

When you are optimizing your DirectQuery model and you have done all the optimizations on the model already, you might want to run the queries generated by Power BI by your DBA. He then might be able to do some index tuning or even suggest some model changes. But how do you capture them? There are a few simple ways that I will describe here.

1 Use DAX studio and Power BI desktop

We will start by opening the report and enabling the performance analyzer. This allows us to get each individual query base on duration so we could optimize them one by one. Click Start recording and refresh visuals to load the entire page and get all the queries send.

Once it has run you can copy the query. This is a DAX query so now we need to get the SQL query.

We can do this by running the query in DAX studio which will give us the SQL Query:

That’s option 1. This is a one by one approach.

1B Use DAX studio and Power BI desktop

I call this option 1B as you can change the flow a bit and just capture all the queries all at once in DAX studio too. Just turn on All Queries in DAX studio. This will show all the queries used for the page. For each query you can double click, execute it and get the SQL Query. Saves you copy and pasting but the result is the same.

2 Use SQL Profiler

Another option is to use good old SQL Profiler. You can connect this to Power BI desktop as well and get all the SQL queries in one swoop. Just connect to the diagnostic port of PBI desktop and capture all the “DirectQuery End” (or begin) event class.

This option is probably best if you want to get all the queries and give them to the DBA all at once.

3 Use log analytics

Now this one only works for Azure Analysis services at the moment but you can also capture the same trace events from profiler with Log Analytics as I described here. Just make sure you querythe same “DirectQuery End” event.

That’s it, several ways to get all the SQL queries generated by Power BI.

Share this:

Let’s block ads! (Why?)

Kasper On BI

DirectQuery, mode, query, used
  • Recent Posts

    • Why Some CRM Initiatives Fail
    • Lucas Brothers To Write And Star In Semi-Autobiographical Comedy For Universal
    • NortonLifeLock’s AI-powered smartphone app blurs out sensitive information in photos
    • WHEN IDEOLOGY TRUMPS TRUTH
    • New Customer Experience Needs and Commerce Trends for 2021
  • Categories

  • Archives

    • February 2021
    • January 2021
    • December 2020
    • November 2020
    • October 2020
    • September 2020
    • August 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • March 2020
    • February 2020
    • January 2020
    • December 2019
    • November 2019
    • October 2019
    • September 2019
    • August 2019
    • July 2019
    • June 2019
    • May 2019
    • April 2019
    • March 2019
    • February 2019
    • January 2019
    • December 2018
    • November 2018
    • October 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • May 2018
    • April 2018
    • March 2018
    • February 2018
    • January 2018
    • December 2017
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • July 2017
    • June 2017
    • May 2017
    • April 2017
    • March 2017
    • February 2017
    • January 2017
    • December 2016
    • November 2016
    • October 2016
    • September 2016
    • August 2016
    • July 2016
    • June 2016
    • May 2016
    • April 2016
    • March 2016
    • February 2016
    • January 2016
    • December 2015
    • November 2015
    • October 2015
    • September 2015
    • August 2015
    • July 2015
    • June 2015
    • May 2015
    • April 2015
    • March 2015
    • February 2015
    • January 2015
    • December 2014
    • November 2014
© 2021 Business Intelligence Info
Power BI Training | G Com Solutions Limited