DAX fundamentals¶
Before memorizing functions, identify what object you are creating and what table grain its answer represents.
| Object | Evaluation/use | Typical choice |
|---|---|---|
| Measure | Evaluated under the query's filter context | Revenue, a ratio, selected-period comparison |
| Calculated column | Row-by-row during processing/refresh in this Import model; stored | A reusable row label or attribute |
| Calculated table | Materialized at refresh/processing | A deliberate calendar or helper dimension |
| Query | Returns a table from the current engine/model | Inspect, test, or benchmark an expression |
| RLS expression | Defines an authorized row filter | Restrict rows for an assigned role |
Storage modes and product support affect availability. A calculated column does not recompute for each slicer click in this Import practice model. Do not describe every possible visual calculation as a saved model measure.
Start with additive values¶
Revenue = SUM ( Sales[SalesAmount] )
Sales is a table; [SalesAmount] is a column. A measure reference such as
[Revenue] asks the engine to evaluate its formula in the current context.
Use fully qualified column references and clear measure names.
Tables with spaces require single quotes, for example 'Sales History'[Amount].
A row-level calculation is a different object¶
Create this with New column on Sales:
Line Profit = Sales[SalesAmount] - Sales[CostAmount]
SaleID 1 gets Line Profit 300. The column stores each row's result. The Gross Profit measure instead subtracts the two filtered aggregates. Both sum to 3080 here, but they are different modeling choices with different storage and evaluation costs.
Ratios are not generally additive¶
Gross Margin % = DIVIDE ( [Gross Profit], [Revenue] )
Total margin is 3080 / 9500 = approximately 32.42%. Summing or taking a simple average of individual row percentages answers a different question. Calculate the numerator and denominator at the requested grain.
Exercise: show ProductName and Revenue in a matrix. Predict 8000, 800, 700, and grand total 9500. Then add margin and explain the total independently.
Inspect context next. Primary reference: DAX overview.