Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for DAX query window #73

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions te3/features/dax-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
uid: dax-query
title: DAX Queries
author: Morten Lønskov
updated: 2023-11-09
applies_to:
editions:
- edition: Desktop
- edition: Business
- edition: Enterprise
---
# DAX Queries

Tabular Editor has a built in DAX query window to write and execute DAX queries against the semantic model.

A very common use case for DAX queries is the DAX query produced by the [Power BI Performance Analyzer](https://www.sqlbi.com/articles/introducing-the-power-bi-performance-analyzer/), where it is possible to copy the query of each visual for troubleshooting, debugging or detailed performance analysis.

The window can be opened while connected to a sematic model by using either the File > New > DAX Query folder or the toolbar shortcut.
mlonsk marked this conversation as resolved.
Show resolved Hide resolved

![Dax Query New](~/images/features/dax_query_window/create_new_dax_query.png)

The built in context aware intellisense ensure that only the two valid DAX keywords are available when starting a new query: DEFINE or EVALUATE (Press Ctrl+Space to verify for yourself)
mlonsk marked this conversation as resolved.
Show resolved Hide resolved

## DAX Query Toolbar

The DAX query window has four different toolbar options.

![Dax Query New](~/images/features/dax_query_window/dax_query_toolbar.png)


1. Execute (F5)
2. Execute Selection (Shift+F5)
3. Stop
4. Auto Execute Query

The Auto Execute Query allows for keeping track of the connected semantic model and update the query results whenever something changes in the model. This can be useful for understanding e.g. how the result of a measure changes if modified.

## DAX Query Example

A DAX query always return a table of results, and the simplest form of DAX query to create is one that evaluates a table within the model.

```DAX
EVALUATE
Products
```
![Dax Query New](~/images/features/dax_query_window/evaluate_table.png)

It is also possible to return the value of a measure but a table constructor {} is required around it measure name
mlonsk marked this conversation as resolved.
Show resolved Hide resolved


```DAX
EVALUATE
{ [Invoice Lines] }
```
![Dax Query New](~/images/features/dax_query_window/evaluate_measusre.png)

### Multiple EVALUATE statements
It is perfectly possible to have multiple EVALUATE statements inside the same DAX query. This type of query is most often encountered with with Power BI Performance Analyzer queries.
mlonsk marked this conversation as resolved.
Show resolved Hide resolved

Both tables are returned in the bellow statement, but as separate row tabs in the result pane as indicated in the example bellow.
mlonsk marked this conversation as resolved.
Show resolved Hide resolved

```DAX
EVALUATE
Products

EVALUATE
Customers
```

![Dax Query New](~/images/features/dax_query_window/multiple_evaluate_table.png)

## Debugging DAX Query
DAX queries is one of the two places where it is possible to run the [DAX Debugger](xrefid:dax-debugger), the other being the Pivot Grid.

The DAX debugger unlocks the ability to understand how the DAX works inside a single cell. To start the debugger simply right click on the desired cell and choose 'Debug cell', which will start the debugger in the context of the chosen cell.

![Dax Query New](~/images/features/dax_query_window/dax_query_open_dax_debugger.gif)

1 change: 1 addition & 0 deletions te3/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
### @perspective-editor
### @metadata-translation-editor
### @dax-debugger
### @dax-query
## @supported-files
### @tmdl
## @preferences
Expand Down
Loading