Power BI DAX Query View [With Examples]

Do you know what DAX Query View is in Power BI Desktop? If not, do not worry!

In this Power BI tutorial, I will explain the Power BI DAX Query View, how to add DAX Query View in Power BI Desktop, and the layout of DAX Query View in Power BI Desktop.

Also, I will explain how to create and run DAX queries with DAX Query View in Power BI, and additionally, I will explain how to work with quick queries in Power BI DAX Query View.

Power BI DAX Query View

  • The DAX Query view is a fourth view in Power BI Desktop that enables you to use the powerful DAX query language.
  • The DAX Query view feature comes in the November 2023 update of Power BI Desktop, which offers a much-improved workflow for BI developers.
  • It’s a way for new Power BI developers to explore and learn how calculations and filters are applied to the data in their reports.
  • In the DAX Query View, DAX queries have two main parts:
    • EVALUATE: It serves as the starting point in the DAX Query View, similar to the “Select” keyword in SQL. However, in DAX Query View, we use “EVALUATE.”
    • DEFINE: It allows you to define DAX formulas.
What is DAX Query View in Power BI

How to Add DAX Query View in Power BI Desktop

I will tell you how to add a DAX Query View to the Power BI Desktop.

1. Open Power BI Desktop -> In the top ribbon, click the File tab.

Add DAX query view in power bi desktop

2. Click the Options and settings -> Click Options.

DAX query view power bi desktop

3. Then new window(Options) opens, select Preview feature -> Check the DAX query view checkbox -> click OK.

how can I get DAX query view in Power BI Desktop

4. After that, close Power BI Desktop and Open one again. Then, you can see the left side of the DAX Query View available.

How to Add DAX Query View in Power BI Desktop

Follow the above steps to add a DAX Query View to Power BI Desktop.

DAX Query View Layout in Power BI Desktop

Now, let me briefly introduce the layout of the DAX Query View in Power BI Desktop.

At this point, I hope you all added DAX Query View. Click on the DAX Query View.

OptionsDescription
RibbonIn the Power BI DAX Query View, this option allows us to format our query, add comments, uncomment, search our query, replace the query, and search for DAX Query commands.
Run DAX QueryRun the selected portion of the DAX query or the whole thing if nothing is selected in the Power BI DAX Query View.
Data paneHere, we can see the model tables and columns used in DAX queries in the Power BI DAX Query View.
Quick queriesAutomatically create DAX queries from tables, columns, and measures in the Power BI DAX Query View.
DAX query viewWe can easily access the DAX query view using this option in the Power BI DAX Query View.
Result windowThe results are shown in the Result window when a query is run in the Power BI DAX Query View.
Query tabsDAX query view can have multiple query tabs, which can be renamed or removed.
dax query view layout in power bi

This is the DAX query view layout in Power BI Desktop.

Create and run DAX queries with Query View in Power BI

Now, I will create and run DAX queries in the Power BI DAX Query view.

I have a SharePoint list(Financial Sample) in this tutorial that we can utilize for this Power BI tutorial.

ColumnsData Types
SegmentSingle line of text
CountrySingle line of text
ProductSingle line of text
SalesCurrency
ProfitCurrency
Unit SoldNumber
How do you create a DAX formula in Power BI dax query view

1. Open Power BI Desktop and load the SharePoint list. Then, we can see the data set in the Data Panel.

Power BI DAX Query View

2. Click on the DAX Query View.

After clicking on the DAX query view, a sample query is shown to get the top 100 rows of one of the tables. When you run it, it shows in the Result Window. In my case, it shows:

EVALUATE
	TOPN(100,'Financial Sample')
New Dax Query View in Power BI

Now, I want to see how many different products are on my table. To do this, follow the below steps.

3. Put the below DAX expression on the DAX Query editor. Then click on the Run button. Then, in the Result window, select Result 2.

EVALUATE
	DISTINCT(SELECTCOLUMNS(
			'Financial Sample',
			"Product Name",
			'Financial Sample'[Product]
		))
Create and run DAX queries with Query View in Power BI

In the Results window, you see six different products are present.

In this way, you can write and run DAX queries with Query View in Power BI.

How to Work with Quick Queries in Power BI DAX Query View

I will show you how to work with quick queries in the Power BI DAX query view.

1. Open Power BI Desktop and load the SharePoint list. Then, we can see the data set in the Data Panel.

Quick query in Power BI DAX query view

2. Click on the DAX Query View -> Under the Data pane, click Tables -> Right-click on the table name(Financial Sample) -> click Quick queries.

Here, you will find some quick queries.

How to find quick queries in the Power BI DAX query view

3. Next, I click on “Show column statistics.” The DAX Query View automatically generates and executes the corresponding code below, and the results are displayed in the Result window.

EVALUATE
UNION (
    ROW (
        "Table", "Financial Sample",
        "Column", "Product",
        "Count", COUNT ( 'Financial Sample'[Product] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[Product] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[Product] ),
        "Min", MIN ( 'Financial Sample'[Product] ),
        "Max", MAX ( 'Financial Sample'[Product] ),
        "Median", "N/A",
        "Mean", "N/A",
        "Standard Deviation", "N/A",
        "Zeros", "N/A",
        "Evens", "N/A",
        "Odds", "N/A",
        "P25", "N/A",
        "P75", "N/A",
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    ),
    ROW (
        "Table", "Financial Sample",
        "Column", " Sales",
        "Count", COUNT ( 'Financial Sample'[ Sales] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[ Sales] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[ Sales] ),
        "Min", MIN ( 'Financial Sample'[ Sales] ),
        "Max", MAX ( 'Financial Sample'[ Sales] ),
        "Median", MEDIAN ( 'Financial Sample'[ Sales] ),
        "Mean", AVERAGE ( 'Financial Sample'[ Sales] ),
        "Standard Deviation", STDEV.P ( 'Financial Sample'[ Sales] ),
        "Zeros", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', 'Financial Sample'[ Sales] = 0 ) ), 0 ),
        "Evens", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[ Sales], 2 ) = 0 ) ), 0 ),
        "Odds", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[ Sales], 2 ) <> 0 ) ), 0 ),
        "P25", PERCENTILE.INC ( 'Financial Sample'[ Sales], 0.25 ),
        "P75", PERCENTILE.INC ( 'Financial Sample'[ Sales], 0.75 ),
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    ),
    ROW (
        "Table", "Financial Sample",
        "Column", "Profit",
        "Count", COUNT ( 'Financial Sample'[Profit] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[Profit] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[Profit] ),
        "Min", MIN ( 'Financial Sample'[Profit] ),
        "Max", MAX ( 'Financial Sample'[Profit] ),
        "Median", MEDIAN ( 'Financial Sample'[Profit] ),
        "Mean", AVERAGE ( 'Financial Sample'[Profit] ),
        "Standard Deviation", STDEV.P ( 'Financial Sample'[Profit] ),
        "Zeros", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', 'Financial Sample'[Profit] = 0 ) ), 0 ),
        "Evens", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[Profit], 2 ) = 0 ) ), 0 ),
        "Odds", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[Profit], 2 ) <> 0 ) ), 0 ),
        "P25", PERCENTILE.INC ( 'Financial Sample'[Profit], 0.25 ),
        "P75", PERCENTILE.INC ( 'Financial Sample'[Profit], 0.75 ),
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    ),
    ROW (
        "Table", "Financial Sample",
        "Column", "Units Sold",
        "Count", COUNT ( 'Financial Sample'[Units Sold] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[Units Sold] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[Units Sold] ),
        "Min", MIN ( 'Financial Sample'[Units Sold] ),
        "Max", MAX ( 'Financial Sample'[Units Sold] ),
        "Median", MEDIAN ( 'Financial Sample'[Units Sold] ),
        "Mean", AVERAGE ( 'Financial Sample'[Units Sold] ),
        "Standard Deviation", STDEV.P ( 'Financial Sample'[Units Sold] ),
        "Zeros", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', 'Financial Sample'[Units Sold] = 0 ) ), 0 ),
        "Evens", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[Units Sold], 2 ) = 0 ) ), 0 ),
        "Odds", COALESCE ( COUNTROWS ( FILTER ( 'Financial Sample', MOD ( 'Financial Sample'[Units Sold], 2 ) <> 0 ) ), 0 ),
        "P25", PERCENTILE.INC ( 'Financial Sample'[Units Sold], 0.25 ),
        "P75", PERCENTILE.INC ( 'Financial Sample'[Units Sold], 0.75 ),
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    ),
    ROW (
        "Table", "Financial Sample",
        "Column", "Country",
        "Count", COUNT ( 'Financial Sample'[Country] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[Country] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[Country] ),
        "Min", MIN ( 'Financial Sample'[Country] ),
        "Max", MAX ( 'Financial Sample'[Country] ),
        "Median", "N/A",
        "Mean", "N/A",
        "Standard Deviation", "N/A",
        "Zeros", "N/A",
        "Evens", "N/A",
        "Odds", "N/A",
        "P25", "N/A",
        "P75", "N/A",
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    ),
    ROW (
        "Table", "Financial Sample",
        "Column", "Segment",
        "Count", COUNT ( 'Financial Sample'[Segment] ),
        "Distinct Values", DISTINCTCOUNTNOBLANK ( 'Financial Sample'[Segment] ),
        "Null Count", COUNTROWS ( 'Financial Sample' ) - COUNT ( 'Financial Sample'[Segment] ),
        "Min", MIN ( 'Financial Sample'[Segment] ),
        "Max", MAX ( 'Financial Sample'[Segment] ),
        "Median", "N/A",
        "Mean", "N/A",
        "Standard Deviation", "N/A",
        "Zeros", "N/A",
        "Evens", "N/A",
        "Odds", "N/A",
        "P25", "N/A",
        "P75", "N/A",
        "Range in Days", "N/A",
        "Range in Months", "N/A",
        "Range in Years", "N/A"
    )
)
How to Work Quick Query in Power BI DAX Query View

This way, you can work with quick queries in Power BI DAX Query View.

Conclusion

I hope this tutorial helps you know about Power BI DAX Query View. In this tutorial, I covered what DAX Query View is in Power BI, how to incorporate DAX Query View in Power BI Desktop, and the layout of DAX Query View in Power BI Desktop.

I also described generating and executing DAX queries using DAX Query View in Power BI. Additionally, I explained how to work with quick queries in Power BI DAX Query View.

Also, you may like some more Power BI tutorials: