Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS MATH

Power BI DAX Introduction


Share

What is DAX?

DAX stands for Data Analysis Expressions.

It is the formula language of Power BI.

You use DAX to add calculations to your data model: new columns, totals, counts, ratios and much more.

DAX is also used in Power Pivot in Excel and in SQL Server Analysis Services, so what you learn here works there too.

Here is a simple DAX formula.

It adds up the Amount column of the Sales table:

Example

Total Sales = SUM(Sales[Amount])

You will create this exact formula in the DAX Measures chapter.


You Have Already Used DAX

In the Date Table chapter, you created the Date table with this formula:

Date = CALENDAR(DATE(2024, 1, 1), DATE(2025, 12, 31))

Then you added a Year column to it:

Year = YEAR('Date'[Date])

Both formulas are DAX.

The first one creates a whole table.

The second one adds a column to a table.


Where DAX Is Used

In Power BI Desktop, you write DAX in three places:

CalculationWhat it createsPoke Mart example
Calculated columnA new column in a table. The formula is calculated once for every row.Sales[Amount], the quantity times the unit price
MeasureA calculation that returns one value, such as a total, for whatever a visual shows.Total Sales, Profit, Margin %
Calculated tableA whole new table.The Date table

Measures are the most important of the three.

Most of the DAX you write will be measures.


DAX vs Excel Formulas

If you know Excel formulas, DAX will look familiar.

Many functions have the same names: SUM, AVERAGE, MIN, MAX, COUNT, IF, LEFT, DATE and many more.

The big difference: Excel formulas work on cells. DAX works on columns and tables.

In Excel, you add up the Sales column of poke_mart_sales.xlsx (the file from First Report) with a range of cells:

Excel

=SUM(I2:I2741)

In DAX, you name the table and the column.

There are no cell addresses:

DAX

Total Sales = SUM(Sales[Amount])

Both formulas return 9,416,800.

Here are the main differences:

Excel formulaDAX formula
Works onCells and ranges, like I2:I2741Columns and tables, like Sales[Amount]
Starts withAn equal sign: =A name and an equal sign: Total Sales =
A formula for every rowYou copy the formula down the column. Each row has its own copy.You write the formula once. It is calculated for every row of the table.
Look up a value in another tableVLOOKUP or XLOOKUPA relationship and the RELATED function
Totals by groupA PivotTableA measure in a visual

A measure works much like a value in the Values area of a PivotTable.

The same measure shows a different number in every row of a visual, because each row has its own filter.

You learn how this works in DAX Measures and DAX Context.

Note: You cannot paste Excel formulas into Power BI.

DAX has no cell references and no ranges.



The Poke Mart Model

This chapter uses the data model you built in the Modeling chapter, from the file poke_mart_model.xlsx:

Download poke_mart_model.xlsx

TableColumnsRows
SalesOrderID, Date, StoreID, ProductID, Quantity2,740
ProductsProductID, Product, Category, UnitPrice, UnitCost10
StoresStoreID, Store, Region6
DateDate, Year, Quarter, Month Number, Month731

Sales is related to Products on ProductID, to Stores on StoreID, and to Date on Date.

Each Sales row is one order.

If you are starting here, build the model first: see Star Schema, Relationships and Date Table.

Note: The Stores sheet holds only text, so Power Query cannot tell its header row from the data, and Stores loads with the columns Column1, Column2 and Column3. After Load, select Transform data, select the Stores query, and on the Home tab select Use First Row as Headers.

Then select Close & Apply.

Power BI now creates the Sales to Stores relationship by itself.

See Star Schema for the details.

Notice that the Sales table has no money columns.

It only knows how many of each product were sold.

In this chapter, you use DAX to calculate the sales amounts and costs, and then totals, profit and margins.

Save the report as poke_mart_dax.pbix (File > Save as > Browse this device), and save it again at the end of each DAX page.

The Visuals chapter continues in this file.


What You Will Learn

The DAX chapter builds up one step at a time:



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.