We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

DAX

DAX stands for Data Analysis Expressions. It's the language that Power BI uses to perform calculations, build metrics, and create dynamic insights in your reports. While it looks a bit like Excel, DAX is designed specifically for analytical models and large datasets.

DAX allows you to create things like totals, averages, percentages, comparisons, KPIs, and time-based calculations that react instantly to slicers and filters in your report. Any time you see a number in a Power BI visual that updates when you click something, DAX is doing the work behind the scenes.

The formulas we wrote in the last chapter were simple DAX expressions.

There are two main places where you can write DAX in Power BI:

  • The formula input that we used for calculated columns and measures
  • The DAX query view

Click to play video

DAX Query View

The DAX query view is a more advanced area where you can write DAX queries to inspect data, test expressions, and debug calculations. It's especially helpful when you want to see exactly what a DAX expression is returning without building a full visual.

Query View is the easiest way to "peek behind the curtain" of your model.

You can open it from the left-hand pane:

Select Columns

This query uses the SELECTCOLUMNS function to create a new table with only the columns we specify. It lets us get a quick view into our data – it's a bit like running a one-off SQL SELECT statement.

EVALUATE
SELECTCOLUMNS(
    sales,
    "sale_price", sales[price],
    "customer_id", sales[customer_id]
)

The EVALUATE statement simply tells DAX to run the query and return the results as a table.

Assignment

Save the project and, from the course directory, submit the CLI tests.