In some situations its useful to determine the DAX queries being utilized by your Power BI reports. Power BI provides a means of capturing the generated DAX queries. The below guide shows how to capture these queries.
Power BI Web
Open the report which you would like to capture the DAX queries from.
On the top of the screen, click the ‘Edit’ button.
Click ‘View’ from the top navigation, and then select ‘Performance analyzer’.
Click the ‘Start recording’ button.
Click the ‘Refresh visuals’ button. This will reload all visualizations and capture the DAX queries used. Note, as seen below multiple queries can be captured.
Click ‘Copy query’ to copy the generated DAX query.
Example of copied DAX query:
// DAX Query
DEFINE
VAR __DS0Core =
SUMMARIZECOLUMNS(
'scores'[School Name],
"SumAverage_Score__SAT_Math_", CALCULATE(SUM('scores'[Average Score (SAT Math)])),
"SumAverage_Score__SAT_Reading_", CALCULATE(SUM('scores'[Average Score (SAT Reading)])),
"SumAverage_Score__SAT_Writing_", CALCULATE(SUM('scores'[Average Score (SAT Writing)]))
)
VAR __DS0PrimaryWindowed =
TOPN(1001, __DS0Core, [SumAverage_Score__SAT_Math_], 0, 'scores'[School Name], 1)
EVALUATE
__DS0PrimaryWindowed
ORDER BY
[SumAverage_Score__SAT_Math_] DESC, 'scores'[School Name]
Power BI Desktop
Click ‘View’ from the top navigation, and then select ‘Performance analyzer’.
Click the ‘Start recording’ button.
Click the ‘Refresh visuals’ button. This will reload all visualizations and capture the DAX queries used. Note, as seen below multiple queries can be captured.
Click on ‘Copy query’ to copy the generated DAX quer, or you can view the query within Power BI Desktop by clicking on ‘Run in DAX query view’.