Tracing a Power BI dataset via DAX Studio

The following steps can be used to trace and analyze a Power BI dataset via DAX Studio:

  1. Within the Power BI Desktop file containing the dataset (import or DirectQuery), create report pages and visuals which represent the most common reporting and analysis use cases: 
    • To simplify this effort, access two or three existing Power BI reports which are highly utilized by business users and create the same visuals in the dataset file.
    • The formatting of these visuals is not important, but it's essential that the visuals include the most common DAX measures, filters, and granularity.
  2. Open the Power BI Desktop file containing the dataset and the sample report visuals from step 1:
    • Power BI Desktop files which do not include a dataset, such as a file with a Live connection to Analysis Services or a Live connection to a published Power BI dataset, will not be visible to DAX Studio.
  1. Open DAX Studio and click the Connect icon on the right-hand side of the Home ribbon:
    • Specify the Power BI dataset from the Connect dialog as shown in the following screenshot:
Connecting to the Power BI dataset via DAX Studio
  1. As shown in the preceding image, DAX Studio can connect to Tabular Server, and even PowerPivot Model, if DAX Studio is launched from an Excel Workbook containing a PowerPivot model.
  2. Click Connect and observe the tables of the Power BI dataset displayed in the metadata pane on the left. 
  3. Click the All Queries icon within the group of Traces icons on the Home tab:
    • The Output window at the bottom will explain that the query trace has started.
    • Select the All Queries tab at the bottom (to the right of Query History).
  4. In the Power BI Desktop file, apply a filter to a slicer or select one of the values within the visuals to cross-highlight the other visuals:
    • The intent of these actions is to mimic normal user behavior when accessing the Power BI report visuals.
    • These actions will generate DAX queries which will be displayed in the All Queries pane of DAX Studio, as shown in the following screenshot:
Tracing results in DAX Studio – All Queries pane
  1. The All Queries pane can be sorted by the Duration column to quickly identify the slowest query, as illustrated in the preceding screenshot. Additionally, hovering over the Query field displays a formatted version of the DAX query, thus making it easy to identify the DAX measure(s) involved. 
  2. Stop the trace via the stop icon in the All Queries pane (above StartTime). 
  3. Double-click a value from the row of the All Queries pane representing the slowest query (for example, Duration = 111) to add this query to the editor window:
    • The values in the User, Database, and Query fields can all be used to add the query to the editor window.
    • Alternatively, the Copy All icon (up arrow) in the All Queries pane can be used to add all queries from the trace to the editor window.
  4. Select the Server Timings icon in the middle of the Home tab to start a new trace: 
    • Select the Server Timings pane that appears at the bottom (to the right of All Queries
  5. With the slowest query from step 7 in the editor window, click the Run icon, or hit F5 to execute the DAX query.

In the following screenshot, the query from the original trace against the Power BI Desktop file (AdWorksEnterpriseDQ), which required 111 ms in duration, was executed in 106 ms from DAX Studio:

The Server Timings window in DAX Studio

As shown in the preceding image, the editor window displays the Internet Net Sales Amt measure, and the Server Timings pane at the bottom identifies the duration of the query (106 ms). Given that the dataset for this example is in DirectQuery mode against a SQL Server database, the T-SQL statement generated and passed to the database server is displayed in the Query field and window to the right (not shown). This T-SQL statement can be easily copied into another application, such as SQL Server Server Management Studio (SSMS), and executed directly against the source or saved as its own .sql file.

For DirectQuery datasets, use traces in DAX Studio to collect the SQL statements associated with the slowest-performing DAX queries. The team responsible for the DirectQuery source (for example, Teradata) may be able to identify the cause of the issue such as the columns referenced in the filter condition. Additionally, if referential integrity is enforced in the DirectQuery data source, ensure that the SQL statements generated use inner join conditions. Inner join SQL statements will be generated if the Assume referential integrity property of the Edit relationship window has been enabled.

As an alternative to the All Queries trace of a Power BI dataset, a new DAX measure could be tested against an existing DAX query. For example, a common grouping query built with the SUMMARIZECOLUMNS() DAX function and stored in a .dax or .msdax file could be opened in DAX Studio. The new DAX measure contained in the dataset could be referenced in the editor window and the query could be executed with a trace running (via Server Timings). The performance results of the new measure could be compared against the baseline results from common measures (for example, Net Sales and Count of Orders) to obtain a sense of relative performance.

Additionally, two DAX measures which return the same results but utilize distinct logic or functions could be tested against each other in DAX Studio to determine which measure is more performant. DAX measures already added to the Power BI dataset can be accessed via the Metadata pane, and DAX measures can also be defined within the Power Query Editor window via the DEFINE clause.

The following URL contains the full syntax of using DAX as a query language http://bit.ly/2FoRF2y.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.144.65