DAX expression basics
DAX calculates from the semantic model
Data Analysis Expressions (DAX) is the formula language used to define calculations over a model. Power Query M prepares tables before import; DAX measures answer questions against the loaded model, using the current filters. Excel formulas often refer to cells such as A2; DAX normally refers to named model tables, columns and measures instead. Use the V007 clean Import model from labs/relationships/README.md: FactSales, DimProduct and DimRegion, active single-direction one-to-many relationships. Currency is USD, one row per order line, Jan 5–7 2026. Clear unrelated filters. Formula snippets are individual New measure definitions, not a DAX query or a single multi-measure script. Use comma argument separators and decimal points (English teaching syntax); local separator settings may differ. All outputs are predicted, native DAX NOT RUN.
Read names, operators and result types
FactSales[Quantity] identifies a column; [Units Sold] identifies a measure when used in an expression. A table containing spaces needs single quotes, for example 'Sales Data'[Quantity]. Text constants use double quotes, numeric literals need no quotes, and TRUE() returns a logical value. Arithmetic uses +, -, *, /; comparisons include =, > and <=; && and || combine logical tests; & joins text. Parentheses make precedence clear. A scalar is one value; a table has rows and columns. A measure must ultimately provide a scalar result, not a multirow table. A column reference by itself does not tell a measure which of several rows to use.
Example 1: create a constant measure
Create these separately in New measure.
Demo Units = (2 + 3) * 4Demo Label = "Retail" & " sales"The first returns 20 and the second returns Retail sales in a card. Neither reads FactSales; changing the region does not change the constants. These are syntax demonstrations, not useful business KPIs.
Example 2: name intermediate results
Demo Profit =VAR Revenue = 120VAR Cost = 75RETURN Revenue - CostThe result is 45. VAR binds an expression result to a local name; RETURN supplies the final expression. A variable does not update like an imperative counter. Each measure evaluation can have different variable values when its inputs depend on filters. For a table-valued example, VALUES(FactSales[Region]) can yield North and South; it is not itself a scalar card measure. COUNTROWS(VALUES(FactSales[Region])) would yield 2 in this clean unfiltered model. We will use COUNTROWS more in the next lesson.
Avoid mixing formula languages
=SUM(A2:A6) is an Excel cell-range formula, not a DAX model measure. Table.SelectRows belongs to M, not DAX. A multirow table expression cannot simply be pasted into a New measure formula to display it as a scalar. Select the result type and execution environment first.
Practice
Complete task 1 of labs/dax-fundamentals/worksheet.md: classify references and predict constant and variable expressions before using the optional Desktop lab.