Basic Aggregation Functions: SUM, AVERAGE, MIN & MAX
Overview & Learning Objectives
The fundamental milestone in mastering DAX is understanding the divide between Calculated Columns and Measures. Calculated Columns compute values row-by-row during data refresh and consume permanent RAM memory. Measures compute on-the-fly in response to user slicers and visual interactions, consuming zero storage memory. Using the wrong one can blow up your model size or make calculations impossible.
- Contrast Calculated Columns (row context, stored in RAM) with Measures (filter context, calculated on demand).
- Identify when a Calculated Column is strictly required (slicers, matrix row headers).
- Follow the golden rule of enterprise BI: "Always use a measure unless you need a row-level slicer."
Industry Standard
Standard: Enterprise modeling governance at Amazon and Microsoft dictates: Never create a Calculated Column if a Measure can accomplish the analytical requirement.
Real-World Example: Scoop & Swirl Ice Cream Parlour
Scoop & Swirl sells scoops with Quantity and Price. We can compute Total Amount as a Column or as a Measure.
| Concept | Storage Location | Evaluation Time | Memory Impact | Ideal Use Case |
|---|---|---|---|---|
| Calculated Column | Stored in RAM (VertiPaq) | At Data Refresh (Row-by-Row) | High (increases .pbix file size) | Slicers, Category Bins, Grouping |
| DAX Measure | Zero Storage (Virtual) | At Query Time (Dynamic Slicing) | Zero RAM storage impact | KPI cards, Totals, Percentages, Trends |
Syntax & Core Workflow
Measure: Total Sales = SUMX(Fact_Sales, Fact_Sales[Quantity] * Fact_Sales[UnitPrice])
Calculated Column: LineTotal = Fact_Sales[Quantity] * Fact_Sales[UnitPrice]
Parameters Breakdown
Row Context: The current row being evaluated; native to Calculated Columns and iterator functions.Filter Context: The active set of filters applied by slicers, visual axes, and report filters; drives Measures.RAM Footprint: Calculated columns are physically stored in the VertiPaq table; measures consume zero storage.Aggregation: Measures always return a single aggregated scalar value (like a total or ratio).
Sample Walkthrough (Q&A)
Question: Can you use a DAX Measure as a Slicer or as the Legend of a Donut Chart?
Formula / Action: No; Slicers and Chart Legends require physical row values from a Table Column.
Result: Only Calculated Columns or imported table columns can slice data.
Explanation: Slicers need a static list of distinct values to render checkboxes. Since a Measure calculates dynamically based on active filters, it cannot be used as a slicer.
Common Mistakes & Limitations
- Creating Calculated Columns for basic metrics (e.g. creating a "Sales" column in every row) instead of writing a reusable DAX measure, inflating model size by 200%.
- Trying to reference a column without an aggregation function inside a Measure (e.g. `[Price] * [Qty]`), causing syntax errors.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Create New Measure | Alt -> Modeling -> New Measure | Click New Measure |
| Create New Column | Alt -> Modeling -> New Column | Click New Column |
Pro Tips & Modern Alternatives
- If you need row-level calculations like `Price * Quantity`, compute them in Power Query or SQL view instead of a DAX Calculated Column for superior VertiPaq compression.
- Always store measures in a dedicated `_Measures` table.